Using ListBox

Post Reply
yardenmo
Posts: 33
Joined: Tue Aug 12, 2008 7:08 am

Using ListBox

Post by yardenmo »

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
User avatar
Antonio Linares
Site Admin
Posts: 42414
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 12 times
Been thanked: 48 times
Contact:

Post by Antonio Linares »

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: 42414
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 12 times
Been thanked: 48 times
Contact:

Post by Antonio Linares »

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: 42414
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 12 times
Been thanked: 48 times
Contact:

Post by Antonio Linares »

Here you have an example:

Code: Select all | Expand

   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
yardenmo
Posts: 33
Joined: Tue Aug 12, 2008 7:08 am

Post by yardenmo »

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

Post by yardenmo »

Antonio,

Does the Combo Box enables incremental search as well?


Thanks,
Moshe Yarden
User avatar
Antonio Linares
Site Admin
Posts: 42414
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 12 times
Been thanked: 48 times
Contact:

Post by Antonio Linares »

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: 42414
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 12 times
Been thanked: 48 times
Contact:

Post by Antonio Linares »

Moshe,

Regarding the SELECT clause here you have an example from FWH:

Code: Select all | Expand

   @ 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
yardenmo
Posts: 33
Joined: Tue Aug 12, 2008 7:08 am

Post by yardenmo »

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
User avatar
Enrico Maria Giordano
Posts: 8736
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 1 time
Contact:

Post by Enrico Maria Giordano »

Code: Select all | Expand

#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: 8736
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 1 time
Contact:

Post by Enrico Maria Giordano »

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

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

Post by yardenmo »

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
User avatar
Enrico Maria Giordano
Posts: 8736
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 1 time
Contact:

Post by Enrico Maria Giordano »

Try

Code: Select all | Expand

IF( EMPTY( aArray ), "", aArray[ 1, nCur ] ),;


etc.

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

Post by yardenmo »

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
User avatar
Enrico Maria Giordano
Posts: 8736
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 1 time
Contact:

Post by Enrico Maria Giordano »

You have to replace

Code: Select all | Expand

Len( aArray )


with

Code: Select all | Expand

Len( aArray[ 1 ] )


EMG
Post Reply