Using ListBox

Using ListBox

Postby yardenmo » Thu Sep 18, 2008 11:50 am

Hi,

I'm trying to use ListBox, to show just those fields matching a predefined
condition, like:
"MasLoad->Manifest == cManifest .and. MasLoad->TalyFlag"

where Manifest is C
and TalyFlag is L

I was trying: SELECT <cField> FOR <uValue1> [ TO <uValue2>]

But I'm doing something wrong.

*. Is there a way to use something like AChoice()?
*. Is there a picklist that does an incremental search as letters are entered?


Thanks,
Moshe Yarden
yardenmo
 
Posts: 33
Joined: Tue Aug 12, 2008 7:08 am

Postby Antonio Linares » Thu Sep 18, 2008 11:55 am

Moshe,

> *. Is there a picklist that does an incremental search as letters are entered?

You have a working examples in FWPPC\samples\TestBrwS.prg :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Thu Sep 18, 2008 11:57 am

Moshe,

> I was trying: SELECT <cField> FOR <uValue1> [ TO <uValue2>]

In order to use that clause, you need to have an index built with the expression to be searched.

Alternatively you can use OrdScope() to set a top and bottom range in the database. Please do a search in these forums for "OrdScope", thanks
Last edited by Antonio Linares on Thu Sep 18, 2008 12:01 pm, edited 1 time in total.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Thu Sep 18, 2008 12:00 pm

Here you have an example:
Code: Select all  Expand view
   DbSelectArea( "bp" )
   bp->( OrdSetFocus( "bpopen" ) )  // it's a conditional index created with FOR ...

   bp->( ordScope( 0, topValue ) )
   bp->( ordScope( 1, bottomValue ) )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby yardenmo » Thu Sep 18, 2008 1:09 pm

Antonio,

Thanks.

I'll try it.

in: SELECT <cField> FOR <uValue1> [ TO <uValue2>]

How do I write cField? is it the name of the field or in " "
and, the uValue1 - is it an expression the returns true / false?


Moshe Yarden
yardenmo
 
Posts: 33
Joined: Tue Aug 12, 2008 7:08 am

Postby yardenmo » Thu Sep 18, 2008 1:12 pm

Antonio,

Does the Combo Box enables incremental search as well?


Thanks,
Moshe Yarden
yardenmo
 
Posts: 33
Joined: Tue Aug 12, 2008 7:08 am

Postby Antonio Linares » Thu Sep 18, 2008 4:37 pm

Moshe,

> Does the Combo Box enables incremental search as well?

We have a version that does it, but some users are reporting some problems with it.

Better do it the way we do it in samples\TestBrwS.prg
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Thu Sep 18, 2008 4:39 pm

Moshe,

Regarding the SELECT clause here you have an example from FWH:
Code: Select all  Expand view
   @ 1, 1 LISTBOX oLbx FIELDS aHBitmaps[ Max( 1, Clientes->Nivel ) ],;
                              Clientes->Nombre, Clientes->Direccion,;
                              Clientes->Telefono, ;
                              Str( Clientes->Edad, 3 ) ;
          HEADERS    "Lev.", "Name", "Address", "Phone", "Age" ;
          FIELDSIZES 34, 240, 310, 114, 24 ;
          SELECT Nombre FOR "Laureano" TO "Paco" ;
          SIZE 284, 137 OF oDlg

Nombre is a field name. "Laureano" is the top value and "Paco" is the bottom value. The index has to use Nombre as the key.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby yardenmo » Thu Sep 18, 2008 5:29 pm

Antonio,

Thanks. It is very helpful.

Is there a way to show a table (like in ListBox) but the items are taken from an array. That way I can fill the array with itmes (dbf records), passing any kind of restrictions, without the need to have many indexes?



Moshe Yarden
yardenmo
 
Posts: 33
Joined: Tue Aug 12, 2008 7:08 am

Postby Enrico Maria Giordano » Thu Sep 18, 2008 5:35 pm

Code: Select all  Expand view
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg, oBrw

    LOCAL aArray := { { "Test1_1", "Test1_2" },;
                      { "Test2_1", "Test2_2" },;
                      { "Test3_1", "Test3_2" } }

    LOCAL nCur := 1

    DEFINE DIALOG oDlg;
           TITLE "Browsing array";
           SIZE 800, 600

    @ 0, 0 LISTBOX oBrw FIELDS IF( EMPTY( aArray ), "", aArray[ nCur, 1 ] ),;
                               IF( EMPTY( aArray ), "", aArray[ nCur, 2 ] );
           SIZE 200, 200;
           HEADERS "Test1", "Test2"

    oBrw:bLogicLen = { || Len( aArray ) }
    oBrw:bGoTop    = { || nCur := 1 }
    oBrw:bGoBottom = { || nCur := Len( aArray ) }
    oBrw:bSkip     = { | nSkip | Skipper( aArray, @nCur, nSkip ) }
    oBrw:cAlias    = "ARRAY"

    ACTIVATE DIALOG oDlg;
             ON INIT oDlg:SetControl( oBrw );
             CENTER

    RETURN NIL


STATIC FUNCTION SKIPPER( aArray, nCur, nSkip )

    LOCAL nOld := nCur

    nCur += nSkip

    IF nCur > LEN( aArray ); nCur = LEN( aArray ); ENDIF
    IF nCur < 1; nCur = 1; ENDIF

    RETURN nCur - nOld


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Enrico Maria Giordano » Thu Sep 18, 2008 7:57 pm

Ops! The above is for FWH. Please test it using FWPPC (remember to change the #include).

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby yardenmo » Mon Sep 22, 2008 8:32 am

Antonio and EMG,

Thanks.

With: SELECT Nombre FOR "Laureano" TO "Paco"
Can the SELECT / FOR be with more than one field?
like: FistName + FamilyName


I was trying EMG's example for arrays. It works good.
My problem is with the multi dimensional array filled from a data base. I'm trying the enclosed code and receive error:


LOCAL aArray := { {}, {}, {} }
LOCAL nCur := 1
LOCAL oWnd, oBrw
//
DO WHILE !MasLoad->( EOF() )
AADD( aArray[1], MasLoad->ContNumber )
AADD( aArray[2], Str( MasLoad->ContSize, 2 ) )
AADD( aArray[3], MasLoad->ContKind )
MasLoad->( dbSkip() )
ENDDO

DEFINE WINDOW oWnd TITLE "Status "

@ 1, 1 LISTBOX oBrw FIELDS;
IF( EMPTY( aArray ), "", aArray[ nCur, 1 ] ),;
IF( EMPTY( aArray ), "", aArray[ nCur, 2 ] ),;
IF( EMPTY( aArray ), "", aArray[ nCur, 3 ] );
HEADERS "Container", "Size", "Type" ;
SIZE 220, 167
oBrw:bLogicLen = { || Len( aArray ) }
oBrw:bGoTop = { || nCur := 1 }
oBrw:bGoBottom = { || nCur := Len( aArray ) }
oBrw:bSkip = { | nSkip | Skipper( aArray, @nCur, nSkip ) }
oBrw:cAlias = "ARRAY"

@ 12, 2 BUTTON "Dlg" SIZE 80, 30 ACTION MsgInfo( aArray[ nCur, 1 ] )

@ 12,17 BUTTON "Done" SIZE 80, 30 ACTION oWnd:End()

ACTIVATE WINDOW oWnd ON CLICK MsgInfo( "Click!" )


Thanks,
Moshe Yarden
yardenmo
 
Posts: 33
Joined: Tue Aug 12, 2008 7:08 am

Postby Enrico Maria Giordano » Mon Sep 22, 2008 10:00 am

Try

Code: Select all  Expand view
IF( EMPTY( aArray ), "", aArray[ 1, nCur ] ),;


etc.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby yardenmo » Mon Sep 22, 2008 12:07 pm

Thanks.

With : IF( EMPTY( aArray ), "", aArray[ 1, nCur ] ),;
It doesn't give error, however it shows just 3 records when there are about 180.

I changed to use 3 arrays and it looks ok now.


Thanks again,

Moshe Yarden
yardenmo
 
Posts: 33
Joined: Tue Aug 12, 2008 7:08 am

Postby Enrico Maria Giordano » Mon Sep 22, 2008 2:13 pm

You have to replace

Code: Select all  Expand view
Len( aArray )


with

Code: Select all  Expand view
Len( aArray[ 1 ] )


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Pocket PC

Who is online

Users browsing this forum: No registered users and 4 guests