about filtering

about filtering

Postby lucasdebeltran » Wed Apr 25, 2012 11:02 am

Hi,

I have a DBF with 2 fields, FSERIE and FNUBER

I have those records:

A 2
A 6

B 1
B 2
B 3

D 1
D 2



I need to filter from B 2 to D 1 so I will have:

B 2
B 3
D 1


But does not work:
Code: Select all  Expand view
cCondicion := "(FIELD->FSERIE >= " +CHR(34)+cFSERIE1+CHR(34)+ ".AND. FIELD->FNUMBER >= " + AllTrim( Str( nNumb1 ) ) + " ) .AND. " + ;
                 "(FIELD->FSERIE <= " +CHR(34)+cFSERIE2+CHR(34)+ " .AND. FIELD->FNUMBER <= " + AllTrim( Str( nNumb2 ) )+")"
 



Please, any clue will be apreciated.

Thanks
Muchas gracias. Many thanks.

Un saludo, Best regards,

Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]

Implementando MSVC 2010, FWH64 y ADO.

Abandonando uso xHarbour y SQLRDD.
User avatar
lucasdebeltran
 
Posts: 1303
Joined: Tue Jul 21, 2009 8:12 am

Re: about filtering

Postby Gale FORd » Wed Apr 25, 2012 1:45 pm

The logic is not correct and I cannot tell if there is a space between fields. Assuming there are no spaces and 2nd field has a fixed length of 1, then try this
Code: Select all  Expand view

cCondicion := [FIELD->FSERIE+FIELD->FNUMBER >= "]+cFSERIE1+AllTrim( Str( nNumb1 ) ) +
   ["
.AND. FIELD->FSERIE+FIELD->FNUMBER <= "]+cFSERIE2+AllTrim( Str( nNumb2 ) )+["]
 
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: about filtering

Postby lucasdebeltran » Wed Apr 25, 2012 2:38 pm

Gale,

Thanks very much for reply.

It does not work fine:

Code: Select all  Expand view
cFSERIE1 := "A"
 nCodigo1 := 24

 cFSERIE2 := "D"
 nCodigo2 := 1




cCondicion := [alltrim(FIELD->FSERIE) + alltrim( str(FIELD->FNUMERO) ) >= "]+cFSERIE1+AllTrim( Str( nCodigo1 ) ) +;
   ["
.AND. alltrim(FIELD->FSERIE) + alltrim( str(FIELD->FNUMERO) ) <= "]+cFSERIE2+AllTrim( Str( nCodigo2 ) )+["]
 




I got:
A3
A4
A5
A6
A7
A8
A9

A24
A25
B1
the rest is fine.

But I don´t know why I get A3, A4, etc that are not on the range I need.
Muchas gracias. Many thanks.

Un saludo, Best regards,

Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]

Implementando MSVC 2010, FWH64 y ADO.

Abandonando uso xHarbour y SQLRDD.
User avatar
lucasdebeltran
 
Posts: 1303
Joined: Tue Jul 21, 2009 8:12 am

Re: about filtering

Postby Marc Vanzegbroeck » Wed Apr 25, 2012 7:32 pm

Hi,

Why you use an index + scope

Code: Select all  Expand view

cFSERIE1 := "A"
nCodigo1 := 24

cFSERIE2 := "D"
nCodigo2 := 1
INDEX ON UPPER(FSERIE)+STR(FNUMERO,2,0)
SET SCOPETOP TO UPPER(cFSERIE1)+STR(nCodigo1,2,0)
SET SCOPEBOTTOM TO UPPER(cFSERIE2)+STR(nCodigo2,2,0)


Regards,
Marc
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: about filtering

Postby lucasdebeltran » Wed Apr 25, 2012 7:39 pm

Marc,

Thank you.

I also tried Scopes at first with no luck.

But with help at the spanish forum I discovered that as my field FSERIE has tree characters long, Scope should be A 000000000000020 instead of A000000000.
Muchas gracias. Many thanks.

Un saludo, Best regards,

Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]

Implementando MSVC 2010, FWH64 y ADO.

Abandonando uso xHarbour y SQLRDD.
User avatar
lucasdebeltran
 
Posts: 1303
Joined: Tue Jul 21, 2009 8:12 am

Re: about filtering

Postby Marc Vanzegbroeck » Wed Apr 25, 2012 7:59 pm

Indeed,

In my example I assumed that FSERIE was 1 character long and FNUMERO a nummeric-field of 2 long.

Regards,
Marc
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: about filtering

Postby lucasdebeltran » Wed Apr 25, 2012 8:19 pm

Yes yes, thank you.

The fault was mine
Muchas gracias. Many thanks.

Un saludo, Best regards,

Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]

Implementando MSVC 2010, FWH64 y ADO.

Abandonando uso xHarbour y SQLRDD.
User avatar
lucasdebeltran
 
Posts: 1303
Joined: Tue Jul 21, 2009 8:12 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 118 guests