Try concatenating a non-numeric character to each..

IF FOO: 'X' EQ BAR: 'X' THEN ....


Perry

-----Original Message-----
From: u2-users-boun...@listserver.u2ug.org 
[mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Rob Sobers
Sent: Friday, August 12, 2011 6:15 AM
To: U2 Users List
Subject: [U2] Comparing numeric strings

Say you have two strings that happen to be nuneric:

FOO = "401.0101"
BAR = "401.0101000"

Since UniBasic is untyped, even though I've wrapped each value in quotes "",
they are treated as numbers.  As a result, FOO EQ BAR evaluates to @TRUE.

In most dynamically typed languages, there's an intuitive way to coerce the
values at run-time (e.g, foo.to_s, foo.ToString, Str(foo)).  I can't seem to
figure out a good way to do this in UniBasic.  In the manual, there's a
function called SCMP that is supposed to be handy for comparing numeric
strings, but it doesn't appear to work in UniData 7.2.

# First try SCMP
IF SCMP(FOO, BAR) THEN
  CRT "Not Equal"
END ELSE
  CRT "Equal"
END

# Now try EQ
IF FOO EQ BAR THEN
  CRT "Equal"
END ELSE
  CRT "Not Equal"
END

Result:
Equal
Equal

Also, the "tip" in the manual seems to be untrue:

"Numbers specified in quotation marks are string data type. Numbers
specified without quotation marks are numeric data type. The data type in a
variable is determined by the data first loaded into it."

Quotation marks appear to have absolutely no bearing on data type.

-Rob
_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

CONFIDENTIALITY NOTICE: This e-mail message, including any 
attachments, is for the sole use of the intended recipient(s) 
and may contain confidential and privileged information.  Any
unauthorized review, use, disclosure or distribution is 
prohibited. ZirMed, Inc. has strict policies regarding the 
content of e-mail communications, specifically Protected Health 
Information, any communications containing such material will 
be returned to the originating party with such advisement 
noted. If you are not the intended recipient, please contact 
the sender by reply e-mail and destroy all copies of the 
original message.
_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

Reply via email to