You could also force a text comparison by doing something like: if X+"" =
Y+"" then ... (although that does make for some ugly looking code ;-)

Larry Hiscock
Western Computer Services

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of
[EMAIL PROTECTED]
Sent: Wednesday, May 12, 2004 7:50 PM
To: [EMAIL PROTECTED]
Subject: RE: [U2] SPACE character ignored


You're right with your guess about numeric equivalence.

Probably the best way to test for this type of thing is to use the COMPARE
function.

Try:

X = "1"
Y = "1 "
IF COMPARE(X,Y) = 0 THEN ...

COMPARE returns -1, 0 or 1 depending on whether the first argument is less
than, equal to or greater than the second.

COMPARE also has a third optional argument of Justification which can be
either "R" or "L" (default "L").

-----Original Message-----
From: Lindsay Gregory [mailto:[EMAIL PROTECTED]
Sent: Thursday, 13 May 2004 10:29
To: [EMAIL PROTECTED]
Subject: [U2] SPACE character ignored


Hi



I am sure this has been covered somewhere before but I could not find under
oliver.com or u2ug.org.



Can anyone tell me why: if



X = '1'

Y = '1 '    ;* note the trailing space character



X = Y is true



But if



X = ''

Y = ' '

X = Y is false



So adding a space character to a text string is ignored but adding a space
character to a null is not ignored.

I can understand why X = ''  is not equal to Y = ' ' because X is not a text
string but if in the first case - the text string Y has two characters - a
one and a space and the text string X has only one character how can they be
equivalent.



My guess is that by the time they come to be tested for equivalence they
have been converted to numeric values and are being tested for numeric
equivalence.



How can I force them to be tested for TXT equivalence?



Do I have to say:



IF X = Y AND LEN(X) = LEN(Y) THEN true



Except  if X = ' 1' and Y = '1 '  then LEN(X) = LEN(Y) ...



It seems that leading or trailing spaces are ignored (but not embedded
spaces) so I have to say



IF LEN(X) = LEN(TRIM(X)) AND LEN(Y) = LEN(TRIM(Y)) AND X = Y THEN true



There has got to be an easier way !!



Lindsay Gregory

Axys (NZ) Ltd

www.axys.co.nz

Ph: +64 9 5200264

Fax +64 9 5200266

Mob +64 21 770 462
-------
u2-users mailing list
[EMAIL PROTECTED]
http://www.u2ug.org/listinfo/u2-users
Disclaimer.  This e-mail is private and confidential. If you are not the
intended recipient, please advise us by return e-mail immediately, and
delete the e-mail and any attachments without using or disclosing the
contents in any way. The views expressed in this e-mail are those of the
author, and do not represent those of this company unless this is clearly
indicated. You should scan this e-mail and any attachments for viruses. This
company accepts no liability for any direct or indirect damage or loss
resulting from the use of any attachments to this e-mail.
-------
u2-users mailing list
[EMAIL PROTECTED]
http://www.u2ug.org/listinfo/u2-users
-------
u2-users mailing list
[EMAIL PROTECTED]
http://www.u2ug.org/listinfo/u2-users

Reply via email to