Re: [U2] Comparing numeric strings

2011-08-12 Thread Boydell, Stuart
Still not that elegant but the quote function worked for me.
0001 a = '401.0101'
0002 b = '401.0101000'
0003 crt 'equal ' :a = b
0004 crt 'quote ' :quote(a) = quote(b)
0005 crt 'comp ' :compare(a,b)

Output:
equal 1
quote 0
comp 1

Cheers,
Stuart

-Original Message-
From: u2-users-boun...@listserver.u2ug.org 
[mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Rob Sobers
Sent: Saturday, 13 August 2011 03:11
To: U2 Users List
Subject: Re: [U2] Comparing numeric strings

Thanks all.  I should have mentioned that I already knew about the 
alpha-concatenation hack. I was sort of looking for a cleaner approach. 



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


Re: [U2] Comparing numeric strings

2011-08-12 Thread Glorfield, Gordon
Unidata has no equivalent to the UV COMPARE function.

-Original Message-
From: u2-users-boun...@listserver.u2ug.org 
[mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of u2ug
Sent: Friday, August 12, 2011 1:20 PM
To: U2 Users List
Subject: Re: [U2] Comparing numeric strings

Have you looked at the COMPARE() function ?
Does the trick under universe.


-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 1:11 PM
To: U2 Users List
Subject: Re: [U2] Comparing numeric strings

Thanks all.  I should have mentioned that I already knew about the
alpha-concatenation hack. I was sort of looking for a cleaner approach.
It looks like SCMP falls down on floating point numbers.  That should
probably be mentioned in the docs, but instead it just fails silently.
;-(

-Rob

On Fri, Aug 12, 2011 at 9:51 AM, Rex Gozar  wrote:

> In July I added to PickWiki:
>
>
> http://www.pickwiki.com/cgi-bin/wiki.pl?UniVerse_Tips_And_Tricks#Forci
> ng_string_comparison_on_numbers
>
> rex
>
> On Fri, Aug 12, 2011 at 8:15 AM, Rob Sobers  wrote:
> > Say you have two strings that happen to be numeric:
> >
> > 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.
> ___
> U2-Users mailing list
> U2-Users@listserver.u2ug.org
> http://listserver.u2ug.org/mailman/listinfo/u2-users
>
___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


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


Re: [U2] Comparing numeric strings

2011-08-12 Thread Rex Gozar
COMPARE() works, just be careful if you're using it for sorting
strings.  Compiling and running the following test program:

GET(ARG.) A ELSE ABORT
GET(ARG.) B ELSE ABORT
X = COMPARE(A, B)
IS.LESS.THAN = (X LT 0)
DISPLAY (IF IS.LESS.THAN THEN "less" ELSE "greater"):" than"
LOCATE(A, B; FOUND; "AL") ELSE NULL
IS.LESS.THAN = (FOUND EQ 1)
DISPLAY (IF IS.LESS.THAN THEN "less" ELSE "greater"):" than"
END

Gives the expected results most of the time:

>TEST 1 2
less than
less than

>TEST A B
less than
less than

But give different results when the second parameter is a substring of
the first:

>TEST AAA AA
less than
greater than

Apparently COMPARE() and LOCATE() use a different algorithm
internally.  LOCATE() gives results similar to SSELECT  and SORT.

rex
Universe 10.3.7
Pick Flavor


On Fri, Aug 12, 2011 at 1:19 PM, u2ug  wrote:
> Have you looked at the COMPARE() function ?
> Does the trick under universe.
___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


Re: [U2] Comparing numeric strings

2011-08-12 Thread u2ug
Have you looked at the COMPARE() function ?
Does the trick under universe.


-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 1:11 PM
To: U2 Users List
Subject: Re: [U2] Comparing numeric strings

Thanks all.  I should have mentioned that I already knew about the
alpha-concatenation hack. I was sort of looking for a cleaner approach.
It looks like SCMP falls down on floating point numbers.  That should
probably be mentioned in the docs, but instead it just fails silently.
;-(

-Rob

On Fri, Aug 12, 2011 at 9:51 AM, Rex Gozar  wrote:

> In July I added to PickWiki:
>
>
> http://www.pickwiki.com/cgi-bin/wiki.pl?UniVerse_Tips_And_Tricks#Forci
> ng_string_comparison_on_numbers
>
> rex
>
> On Fri, Aug 12, 2011 at 8:15 AM, Rob Sobers  wrote:
> > Say you have two strings that happen to be numeric:
> >
> > 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.
> ___
> U2-Users mailing list
> U2-Users@listserver.u2ug.org
> http://listserver.u2ug.org/mailman/listinfo/u2-users
>
___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


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


Re: [U2] Comparing numeric strings

2011-08-12 Thread Rob Sobers
Thanks all.  I should have mentioned that I already knew about the
alpha-concatenation hack. I was sort of looking for a cleaner approach.  It
looks like SCMP falls down on floating point numbers.  That should probably
be mentioned in the docs, but instead it just fails silently. ;-(

-Rob

On Fri, Aug 12, 2011 at 9:51 AM, Rex Gozar  wrote:

> In July I added to PickWiki:
>
>
> http://www.pickwiki.com/cgi-bin/wiki.pl?UniVerse_Tips_And_Tricks#Forcing_string_comparison_on_numbers
>
> rex
>
> On Fri, Aug 12, 2011 at 8:15 AM, Rob Sobers  wrote:
> > Say you have two strings that happen to be numeric:
> >
> > 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.
> ___
> U2-Users mailing list
> U2-Users@listserver.u2ug.org
> http://listserver.u2ug.org/mailman/listinfo/u2-users
>
___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


Re: [U2] Comparing numeric strings

2011-08-12 Thread Rex Gozar
In July I added to PickWiki:

http://www.pickwiki.com/cgi-bin/wiki.pl?UniVerse_Tips_And_Tricks#Forcing_string_comparison_on_numbers

rex

On Fri, Aug 12, 2011 at 8:15 AM, Rob Sobers  wrote:
> Say you have two strings that happen to be numeric:
>
> 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.
___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


Re: [U2] Comparing numeric strings

2011-08-12 Thread Keith Davison
Hi,

I think the SCMP command is failing because of the decimal place. If you 
take that out you will see it work correctly.

FOO = "401010" 
BAR = "40101000" 
CRT SCMP(FOO,BAR)
-1

FOO = "401010" 
BAR = "401010" 
CRT SCMP(FOO,BAR)
0

FOO = "4010100" 
BAR = "401010" 
CRT SCMP(FOO,BAR)
1

SCMP RESULT
FOO < BAR = -1
FOO = BAR = 0
FOO > BAR = 1





From:   Rob Sobers 
To: U2 Users List 
Date:   12/08/2011 13:16
Subject:[U2] Comparing numeric strings
Sent by:u2-users-boun...@listserver.u2ug.org



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

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


Re: [U2] Comparing numeric strings

2011-08-12 Thread Dave Laansma
Call me a hack ... go ahead

"A":FOO < "A":BAR

"Numeric string" is an oxymoron in any language, I believe.

Sincerely,
David Laansma
IT Manager
Hubbard Supply Co.
Direct: 810-342-7143
Office: 810-234-8681
Fax: 810-234-6142
www.hubbardsupply.com
"Delivering Products, Services and Innovative Solutions"

-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 8: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
___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


Re: [U2] Comparing numeric strings

2011-08-12 Thread Perry Taylor
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


Re: [U2] Comparing numeric strings

2011-08-12 Thread Symeon Breen

Add a space to the end to force it as a string

e.g. 

IF (FOO:' ') = (BAR:' ')



-Original Message-
From: u2-users-boun...@listserver.u2ug.org
[mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Rob Sobers
Sent: 12 August 2011 13:15
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
-
No virus found in this message.
Checked by AVG - www.avg.com
Version: 10.0.1392 / Virus Database: 1520/3822 - Release Date: 08/08/11

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


[U2] Comparing numeric strings

2011-08-12 Thread Rob Sobers
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