FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Listbox Filter on Logical Field
Posts: 105
Joined: Fri Jun 09, 2006 03:27 PM

Listbox Filter on Logical Field

Posted: Tue Jun 27, 2006 06:32 PM

Greetings....
I have a Listbox that I want to show only items that are .t. for a logical field (field->template) in some views and all the data in another view.

Using the Set Filter command works but is slow. Ive tried to set up an Index on that logical field but am getting an index error.

INDEX ON field->template + field->custno where template is logical and custno is character. Can you do an Index on a logical field? Or is there a better way to accomplish what I am trying to do?

I would then use the SET SCOPE or SELECT function for the Listbox. Any guidance on this is appreciated!

Greg

Regards,

Greg Gammon
Posts: 83
Joined: Tue Nov 08, 2005 11:09 AM

Listbox Filter on Logical Field

Posted: Tue Jun 27, 2006 07:25 PM

convert field type to string when indexing :-

index on transform(template,'@!')+custno

Regards

Hoe, email: easywin3@yahoo.com
Posts: 105
Joined: Fri Jun 09, 2006 03:27 PM

Listbox Filter on Logical Field

Posted: Tue Jun 27, 2006 08:13 PM

Ok, that fixes the Index problem fine...thanks!

Next issue is the Listbox.

I use:

REDEFINE LISTBOX oLbx ..... SELECT estmain->template FOR .t. ;

In runtime, I get this ALERT message:
TWBrowse SetFilter() types don't match with current Index type.

You click OK on this Alert and the Listbox pops up and displays perfectly.

Other ideas? (or how to disable that Alert message?)

Thanks!
Greg

Regards,

Greg Gammon
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Listbox Filter on Logical Field

Posted: Tue Jun 27, 2006 09:19 PM

Greg,

transform(template,'@!')+custno is not a logical value.

You may use:
... SELECT transform(template,'@!')+custno FOR ...

Anyhow, you may modify source\classes\wbrowse.prg and comment out the MsgAlert() call.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 105
Joined: Fri Jun 09, 2006 03:27 PM

Listbox Filter on Logical Field

Posted: Tue Jun 27, 2006 09:53 PM

using the SELECT transform(field->template, "@!") FOR "T" works perfectly (of course).
Thanks again!

Regards,

Greg Gammon
Posts: 105
Joined: Fri Jun 09, 2006 03:27 PM

Listbox Filter on Logical Field

Posted: Fri Jun 30, 2006 02:24 PM

Have another issue with this...
My index is INDEX ON transform(field->logical, '@!')+field->custno

Is it possible to set scope or use the Listbox...Select/For command using both Index keys?

For instance...Set Scope To "T"+oCustno ? I can't seem to make anything work in this regard.

Thanks,
Greg

Regards,

Greg Gammon
Posts: 83
Joined: Tue Nov 08, 2005 11:09 AM

Listbox Filter on Logical Field

Posted: Fri Jun 30, 2006 04:03 PM

is oCustno an object or a string ? it must be a string value

Regards

Hoe, email: easywin3@yahoo.com
Posts: 105
Joined: Fri Jun 09, 2006 03:27 PM

Listbox Filter on Logical Field

Posted: Fri Jun 30, 2006 05:07 PM

yes oCustno is a string value...i should have represented that differently in my example.

What i have tried is this:

cCustno := "string"

SET ORDER TO "T"+cCustno

Regards,

Greg Gammon
Posts: 83
Joined: Tue Nov 08, 2005 11:09 AM

Listbox Filter on Logical Field

Posted: Sat Jul 01, 2006 05:19 AM

index on transform(template,'@!')+custno tag tempcust to yourcdx
set order to tag tempcust

redefine listbox oLbx ... ;
select transform(template,'@!')+custno for "T"+cCustno

Regards

Hoe, email: easywin3@yahoo.com
Posts: 105
Joined: Fri Jun 09, 2006 03:27 PM

Listbox Filter on Logical Field

Posted: Sat Jul 01, 2006 01:49 PM

That is exactly what I did do and it doesn't seem to work. Can't understand why but I'll keep plugging away at it. Thanks again.
G

Regards,

Greg Gammon
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM

Listbox Filter on Logical Field

Posted: Sat Jul 01, 2006 03:42 PM

Why not use scopes?

(cAlias)->ordScope(0,"T"+cCustno)
(cAlias)->ordScope(1,"T"+cCustno)

Note that cCustno needs to be exactly the same length as the CUSTNO field.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 105
Joined: Fri Jun 09, 2006 03:27 PM

Listbox Filter on Logical Field

Posted: Sat Jul 01, 2006 11:42 PM

ahhhh.....I did try ordscope but didn't take into account the exact length for cCustno.

Im not sure I exactly grasp the numerical indicator in the ordscope(0,...)
I tried using a 1 not sure what I was doing, so any explanation is helpful...the help files I read did not compute...laugh

I also did Ordscope(1, cAlias->...) Didn't think about the alias being outside ordscope. Why is that?

thanks!
G

Regards,

Greg Gammon
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM

Listbox Filter on Logical Field

Posted: Sun Jul 02, 2006 05:40 PM

Greg,

Zero is the top scope--think of it as <=. One is the top scope, think of it as >=.

The alias here is not referring to the scope value (cCustno), but the scope function.

For safe programming force the var, cCustno, to be the length of the field:

cCustno:= padr(cCustno, len(field->custno))

This way if you ever change the length of the field it won't break your code.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM

Listbox Filter on Logical Field

Posted: Sun Jul 02, 2006 06:30 PM

I noticed that I made a syntax mistake, ordScope should be surrounded with parentheses like this:

(cAlias)->(ordScope(0,"T"+cCustno))
(cAlias)->(ordScope(1,"T"+cCustno))

You might also want to consider using database objects which frees you from using aliases and also provides lots of other benefits. There are a couple of articles about this on my website (see link button below).

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10

Continue the discussion