Listbox Filter on Logical Field

Listbox Filter on Logical Field

Postby Greg Gammon » Tue Jun 27, 2006 6: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
User avatar
Greg Gammon
 
Posts: 105
Joined: Fri Jun 09, 2006 3:27 pm
Location: Bryan, Texas

Postby tnhoe » Tue Jun 27, 2006 7:25 pm

convert field type to string when indexing :-

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

Hoe, email: easywin3@yahoo.com
User avatar
tnhoe
 
Posts: 83
Joined: Tue Nov 08, 2005 11:09 am
Location: Malaysia

Postby Greg Gammon » Tue Jun 27, 2006 8: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
User avatar
Greg Gammon
 
Posts: 105
Joined: Fri Jun 09, 2006 3:27 pm
Location: Bryan, Texas

Postby Antonio Linares » Tue Jun 27, 2006 9: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Greg Gammon » Tue Jun 27, 2006 9:53 pm

using the SELECT transform(field->template, "@!") FOR "T" works perfectly (of course).
Thanks again!
User avatar
Greg Gammon
 
Posts: 105
Joined: Fri Jun 09, 2006 3:27 pm
Location: Bryan, Texas

Postby Greg Gammon » Fri Jun 30, 2006 2: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
User avatar
Greg Gammon
 
Posts: 105
Joined: Fri Jun 09, 2006 3:27 pm
Location: Bryan, Texas

Postby tnhoe » Fri Jun 30, 2006 4:03 pm

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

Hoe, email: easywin3@yahoo.com
User avatar
tnhoe
 
Posts: 83
Joined: Tue Nov 08, 2005 11:09 am
Location: Malaysia

Postby Greg Gammon » Fri Jun 30, 2006 5: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
User avatar
Greg Gammon
 
Posts: 105
Joined: Fri Jun 09, 2006 3:27 pm
Location: Bryan, Texas

Postby tnhoe » Sat Jul 01, 2006 5: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
User avatar
tnhoe
 
Posts: 83
Joined: Tue Nov 08, 2005 11:09 am
Location: Malaysia

Postby Greg Gammon » Sat Jul 01, 2006 1: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
User avatar
Greg Gammon
 
Posts: 105
Joined: Fri Jun 09, 2006 3:27 pm
Location: Bryan, Texas

Postby James Bott » Sat Jul 01, 2006 3: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Greg Gammon » 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
User avatar
Greg Gammon
 
Posts: 105
Joined: Fri Jun 09, 2006 3:27 pm
Location: Bryan, Texas

Postby James Bott » Sun Jul 02, 2006 5: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby James Bott » Sun Jul 02, 2006 6: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).
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 98 guests