Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can be use 0x7FFFFFFF value for max value of chr fields ?

Status
Not open for further replies.

kosta

Programmer
Feb 9, 2001
186
CA
hi all,
i wantto use this value in my query forms, via between command , i know that 0x7FFFFFFF value using with integer fields . Is it possible to use this value for char fields or which method can be use instead of this value for catch max value for this char fiels

TIA


with thisform
lcMinCustID=min(.text1.value,.text2.value)
lcMaxCustID=Max(.text1.value,.text2.value)
lcMaxCustID=iif(empty(.text2.value,0x7FFFFFFF,.text2.value)
endwith
...

select * from customers where custid between lcminCustID and lcmaxCustID into cursor CrsCustomers




Soykan OEZCELIK
 
I think MAX() in character fields is about the alphabetical order. So f.e. 'zzzzzzzzzz' can be maximum, or CHR(255)+CHR(255)+CHR(255)+... if you use all characters, not letters only. -> 0xFF...FFFFFF is maximum.
 
Whether you use "Z", "z", or CHR(255) you can use the REPLICATE and FSIZE functions to build yourself a string the exact length of the field:
Code:
lcMaxCustID=REPLICATE("Z", FSIZE("CustID"))

Geoff Franklin
 
Soykan,

Are you saying that you want to create a charcter string in which all the bits are set to 1?

If so, I would slightly modify the Alvechurch solution:

Code:
lcMaxCustID=REPLICATE(CHR(255), FSIZE("CustID"))

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Hi Mike,
first i want to list custid's between text1 and text2 and also if both of text1 and tex2 empty it will return .t. and will list all records else
it will take min text1 value and if empty text2 it will accept max value of custid

hope that i explained :(

Soykan OEZCELIK
 
Soykan,

In other words, if Text2 is empty, you want to treat it as "the highest possible value".

I think my solution will do that (except that you will get a syntax error in your IIF(EMPTY( .. code because of a missing parenthesis).

In fact, instead of CHR(255), you could use the highest possible value for a single character in your cust ID. For example, if the Cust ID can only contain digits and capital letters, you can use Z as Geoff suggested. But if it might contain accented letters, better stick with CHR(255).

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
-> MikeLewis:
>> But if it might contain accented letters

It depends on current SET COLLATE, so if proper collating is set for the language, then f.e. MAX() returns the value which is last one in the alphabetical order.
 
Foxdbs,

It depends on current SET COLLATE, so if proper collating is set for the language, then f.e. MAX() returns the value which is last one in the alphabetical order.

True, but that's not the point I was making.

My point was that he could not use "Z" in the replicate function if the ID contains accented letters, because it wouldn't give the correct "highest possible value". The collating sequence does not affect that.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Hi again Mike,
CustID can be letter or digit like A-0001 or 9888A or AAAA or 999999 etc.. so that i should catch if empty text2 value code should accept highest custid or value ..

if you were me or if you need these solution how would be the your code ?

TIA


Soykan OEZCELIK
 
Soykan,

if you were me or if you need these solution how would be the your code ?

Something like this:

Code:
with thisform
lcMinCustID=min(.text1.value,.text2.value)
lcMaxCustID=Max(.text1.value,.text2.value)
lcHiVals = REPLICATE("Z",FSIZE("CustID"))
lcMaxCustID=iif(empty(lcMaxCustID),lcHiVals,lcMaxCustID)
endwith
...

select * from customers where custid between lcminCustID and lcmaxCustID into cursor CrsCustomers
Does that help?

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top