Bill Brutzman | 20 Jul 2012 22:22

[U2] Comparing Two Dyamic Arrays

Begin case
          Case array1 = array2  ;  sameThing = true
      Case 1                                ;  sameThing = false
End   case

When I tried to use an equals sign... I did not get the right answer.

While the COMPARE function works ok... and I presume that it is a compiler thing...

It is not clear to me why the equals sign has been disempowered.

Insights would be appreciated.

--Bill
_______________________________________________
U2-Users mailing list
U2-Users <at> listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

Wjhonson | 20 Jul 2012 23:29
Picon
Favicon

Re: [U2] Comparing Two Dyamic Arrays


1) You have not set the values of true and false correctly
2) You are comparing numeric strings without normalizing them

-----Original Message-----
From: Bill Brutzman <billb <at> hkmetalcraft.com>
To: U2 Users List <u2-users <at> listserver.u2ug.org>
Sent: Fri, Jul 20, 2012 1:49 pm
Subject: [U2] Comparing Two Dyamic Arrays

Begin case
         Case array1 = array2  ;  sameThing = true
     Case 1                                ;  sameThing = false
nd   case
When I tried to use an equals sign... I did not get the right answer.
While the COMPARE function works ok... and I presume that it is a compiler 
hing...
It is not clear to me why the equals sign has been disempowered.
Insights would be appreciated.
--Bill
______________________________________________
2-Users mailing list
2-Users <at> listserver.u2ug.org
ttp://listserver.u2ug.org/mailman/listinfo/u2-users

_______________________________________________
U2-Users mailing list
U2-Users <at> listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

(Continue reading)

Bill Brutzman | 21 Jul 2012 02:10

Re: [U2] Comparing Two Dyamic Arrays

Will;
0. Thanks for writing.
1. I tried the true and false via the equate statement... and also tried it with 1 and 0.   All of the gory code was
not included.
2. In U2, it is not clear to me what is meant by "Normalizing".

--Bill

-----Original Message-----
From: u2-users-bounces <at> listserver.u2ug.org [mailto:u2-users-bounces <at> listserver.u2ug.org] On
Behalf Of Wjhonson
Sent: Friday, July 20, 2012 5:30 PM
To: u2-users <at> listserver.u2ug.org
Subject: Re: [U2] Comparing Two Dyamic Arrays

1) You have not set the values of true and false correctly
2) You are comparing numeric strings without normalizing them

-----Original Message-----
From: Bill Brutzman <billb <at> hkmetalcraft.com>
To: U2 Users List <u2-users <at> listserver.u2ug.org>
Sent: Fri, Jul 20, 2012 1:49 pm
Subject: [U2] Comparing Two Dyamic Arrays

Begin case
         Case array1 = array2  ;  sameThing = true
     Case 1                                ;  sameThing = false
nd   case
When I tried to use an equals sign... I did not get the right answer.
While the COMPARE function works ok... and I presume that it is a compiler hing...
(Continue reading)

Wjhonson | 21 Jul 2012 02:44
Picon
Favicon

Re: [U2] Comparing Two Dyamic Arrays


When you compare numeric strings you can get odd results if you do not first *normalize* them into pure
numbers, instead of strings.

You can force this by doing something like A = A + 0, but for an array you would have to act upon each multivalue singly.
This is what the COMPARE function does itself in right justification mode, but a normal equate will *not* do
the same way

-----Original Message-----
From: Bill Brutzman <billb <at> hkmetalcraft.com>
To: U2 Users List <u2-users <at> listserver.u2ug.org>
Sent: Fri, Jul 20, 2012 5:37 pm
Subject: Re: [U2] Comparing Two Dyamic Arrays

Will;
. Thanks for writing.
. I tried the true and false via the equate statement... and also tried it with 
 and 0.   All of the gory code was not included.
. In U2, it is not clear to me what is meant by "Normalizing".
--Bill
-----Original Message-----
rom: u2-users-bounces <at> listserver.u2ug.org [mailto:u2-users-bounces <at> listserver.u2ug.org] 
n Behalf Of Wjhonson
ent: Friday, July 20, 2012 5:30 PM
o: u2-users <at> listserver.u2ug.org
ubject: Re: [U2] Comparing Two Dyamic Arrays

) You have not set the values of true and false correctly
) You are comparing numeric strings without normalizing them

(Continue reading)

Wjhonson | 21 Jul 2012 02:53
Picon
Favicon

Re: [U2] Comparing Two Dyamic Arrays


Universe 10.3

FFT.BP 'TESTEQ'

0001 A = "2.2": <at> VM:"2.20"
0002 B = 2.2: <at> VM:2.2
0003 IF A = B THEN PRINT "YES" ELSE PRINT "NO"
0004 PRINT COMPARE(A,B,"R")

Output result

NO
0

The NO indicates the string array and the numeric array are NOT the same
The "0" however indicates that as far as COMPARE on "R"ight justification they ARE the same

>From a mathematical standpoint, they are the same, we can see that.  The system does not force a match
however on a straight equality test.
COMPARE with Right just does something different however

-----Original Message-----
From: Bill Brutzman <billb <at> hkmetalcraft.com>
To: U2 Users List <u2-users <at> listserver.u2ug.org>
Sent: Fri, Jul 20, 2012 5:37 pm
Subject: Re: [U2] Comparing Two Dyamic Arrays

Will;
. Thanks for writing.
(Continue reading)

Woodward, Bob | 21 Jul 2012 00:43

Re: [U2] Comparing Two Dynamic Arrays

Is it a DIM array or a DYNAMIC array?  I would think that a DIM array
would probably be false because it's space is assigned in memory using
initial values of whatever data was in that location.  I would expect a
DYNAMIC array to work, though, as it's really just a single location in
memory.  No proof but that's what I'd expect, anyway.

BobW

-----Original Message-----
From: u2-users-bounces <at> listserver.u2ug.org
[mailto:u2-users-bounces <at> listserver.u2ug.org] On Behalf Of Bill Brutzman
Sent: Friday, July 20, 2012 1:23 PM
To: U2 Users List
Subject: [U2] Comparing Two Dyamic Arrays

Begin case
          Case array1 = array2  ;  sameThing = true
      Case 1                                ;  sameThing = false
End   case

When I tried to use an equals sign... I did not get the right answer.

While the COMPARE function works ok... and I presume that it is a
compiler thing...

It is not clear to me why the equals sign has been disempowered.

Insights would be appreciated.

--Bill
(Continue reading)

Bill Brutzman | 21 Jul 2012 01:57

Re: [U2] Comparing Two Dynamic Arrays

1. These are Dynamic Arrays... as indicated in the Subject field of the original post.
2. Yes... I also expected the equals to work... it does not... that why I wrote.

--Bill

-----Original Message-----
From: u2-users-bounces <at> listserver.u2ug.org [mailto:u2-users-bounces <at> listserver.u2ug.org] On
Behalf Of Woodward, Bob
Sent: Friday, July 20, 2012 6:44 PM
To: U2 Users List
Subject: Re: [U2] Comparing Two Dynamic Arrays

Is it a DIM array or a DYNAMIC array?  I would think that a DIM array would probably be false because it's space
is assigned in memory using initial values of whatever data was in that location.  I would expect a DYNAMIC
array to work, though, as it's really just a single location in memory.  No proof but that's what I'd expect, anyway.

BobW

-----Original Message-----
From: u2-users-bounces <at> listserver.u2ug.org
[mailto:u2-users-bounces <at> listserver.u2ug.org] On Behalf Of Bill Brutzman
Sent: Friday, July 20, 202 1:23 PM
To: U2 Users List
Subject: [U2] Comparing Two Dyamic Arrays

Begin case
          Case array1 = array2  ;  sameThing = true
      Case 1                                ;  sameThing = false
End   case

(Continue reading)

Bill Haskett | 21 Jul 2012 02:14
Favicon

Re: [U2] Comparing Two Dynamic Arrays

Bill:

I'm wondering if there are trailing attributes in one array vs the other 
array.  I use such code as you've posted many times.  I'd hate to think 
such basic functionality can get broken.

Bill

------------------------------------------------------------------------
----- Original Message -----
*From:* billb <at> hkmetalcraft.com
*To:* U2 Users List <u2-users <at> listserver.u2ug.org>
*Date:* 7/20/2012 4:57 PM
*Subject:* Re: [U2] Comparing Two Dynamic Arrays
> 1. These are Dynamic Arrays... as indicated in the Subject field of the original post.
> 2. Yes... I also expected the equals to work... it does not... that why I wrote.
>
> --Bill
>
> -----Original Message-----
> From: u2-users-bounces <at> listserver.u2ug.org [mailto:u2-users-bounces <at> listserver.u2ug.org] On
Behalf Of Woodward, Bob
> Sent: Friday, July 20, 2012 6:44 PM
> To: U2 Users List
> Subject: Re: [U2] Comparing Two Dynamic Arrays
>
> Is it a DIM array or a DYNAMIC array?  I would think that a DIM array would probably be false because it's space
is assigned in memory using initial values of whatever data was in that location.  I would expect a DYNAMIC
array to work, though, as it's really just a single location in memory.  No proof but that's what I'd expect, anyway.
>
(Continue reading)

Israel, John R. | 21 Jul 2012 03:00

Re: [U2] Comparing Two Dynamic Arrays

Does one have an extra but empty attribute?

For testing only, try comparing array1 = array1 and see what you get.

John Israel

Sent from my iPhone

On Jul 20, 2012, at 8:57 PM, "Bill Brutzman" <billb <at> hkmetalcraft.com> wrote:

> 1. These are Dynamic Arrays... as indicated in the Subject field of the original post.
> 2. Yes... I also expected the equals to work... it does not... that why I wrote.
> 
> --Bill
> 
> -----Original Message-----
> From: u2-users-bounces <at> listserver.u2ug.org [mailto:u2-users-bounces <at> listserver.u2ug.org] On
Behalf Of Woodward, Bob
> Sent: Friday, July 20, 2012 6:44 PM
> To: U2 Users List
> Subject: Re: [U2] Comparing Two Dynamic Arrays
> 
> Is it a DIM array or a DYNAMIC array?  I would think that a DIM array would probably be false because it's space
is assigned in memory using initial values of whatever data was in that location.  I would expect a DYNAMIC
array to work, though, as it's really just a single location in memory.  No proof but that's what I'd expect, anyway.
> 
> BobW
> 
> -----Original Message-----
> From: u2-users-bounces <at> listserver.u2ug.org
(Continue reading)

Ed Clark | 21 Jul 2012 02:10

Re: [U2] Comparing Two Dynamic Arrays

Have you tried examining the strings?

The equal sign will work if the 2 strings are the same. But they can be equal as dynamic arrays while not equal
as strings. For example, on universe:

0001 A="1": <at> AM:"2"
0002 B="1": <at> AM:" 2 "
0003 CRT A=B
0004 CRT EQS(A,B)

prints:
0
1^1

The 2 dynamic arrays aren't equal as strings, but they are as dynamic arrays, because universe ignores
leading/trailing spaces in numeric conversion. Similarly:

0001 A="1": <at> AM:"2": <at> VM
0002 B="1": <at> AM:"2"
0003 CRT A=B
0004 CRT EQS(A,B)

print:
0
1^1]1

they are different strings, but eqs() treats empty and missing values as the same.

On Jul 20, 2012, at 6:43 PM, Woodward, Bob wrote:

(Continue reading)

George Gallen | 23 Jul 2012 15:16

Re: [U2] Comparing Two Dyamic Arrays

Does len(array1)=len(array2) ?

-----Original Message-----
From: u2-users-bounces <at> listserver.u2ug.org [mailto:u2-users-bounces <at> listserver.u2ug.org] On
Behalf Of Bill Brutzman
Sent: Friday, July 20, 2012 4:23 PM
To: U2 Users List
Subject: [U2] Comparing Two Dyamic Arrays

Begin case
          Case array1 = array2  ;  sameThing = true
      Case 1                                ;  sameThing = false
End   case

When I tried to use an equals sign... I did not get the right answer.

While the COMPARE function works ok... and I presume that it is a compiler thing...

It is not clear to me why the equals sign has been disempowered.

Insights would be appreciated.

--Bill
_______________________________________________
U2-Users mailing list
U2-Users <at> listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users
_______________________________________________
U2-Users mailing list
U2-Users <at> listserver.u2ug.org
(Continue reading)

Mike Farrant | 23 Jul 2012 22:17

Re: [U2] Comparing Two Dyamic Arrays

Try:
ResultArray =  EQS(Array1, Array2)
If sum(ResultArray)=0 then samething = true else samething = false

-----Original Message-----
From: u2-users-bounces <at> listserver.u2ug.org
[mailto:u2-users-bounces <at> listserver.u2ug.org] On Behalf Of George Gallen
Sent: 23 July 2012 09:17
To: U2 Users List
Subject: Re: [U2] Comparing Two Dyamic Arrays

Does len(array1)=len(array2) ?

-----Original Message-----
From: u2-users-bounces <at> listserver.u2ug.org
[mailto:u2-users-bounces <at> listserver.u2ug.org] On Behalf Of Bill Brutzman
Sent: Friday, July 20, 2012 4:23 PM
To: U2 Users List
Subject: [U2] Comparing Two Dyamic Arrays

Begin case
          Case array1 = array2  ;  sameThing = true
      Case 1                                ;  sameThing = false
End   case

When I tried to use an equals sign... I did not get the right answer.

While the COMPARE function works ok... and I presume that it is a
compiler thing...

(Continue reading)

Bill Haskett | 23 Jul 2012 22:46
Favicon

Re: [U2] Comparing Two Dyamic Arrays

I'm not sure this would work, as the UniData documentation for "EQS" states:

The UniBasic EQS function compares each value in array1 to its corresponding
value in array2. UniData returns an array with 1 in each position where 
values are
equal, and 0 in each position for values that are not equal.

Thus, if the following...

ARRAY1 = '11': <at> VM:'12': <at> VM:'13': <at> VM:'20': <at> VM:'21'
ARRAY2 = '11': <at> VM:'12': <at> VM:'13': <at> VM:'19': <at> VM:'22'
ARRAY3 = EQS(ARRAY1,ARRAY2)

...then the resultant ARRAY3 would look like:

'1': <at> VM:'1': <at> VM:'1': <at> VM:'0': <at> VM:'0'

On the other hand, the following...

ARRAY1 = '11': <at> VM:'12': <at> VM:'13': <at> VM:'20': <at> VM:'21'
ARRAY2 = '11': <at> VM:'12': <at> VM:'13': <at> VM:'20': <at> VM:'21'
ARRAY3 = EQS(ARRAY1,ARRAY2)

...would assign ARRAY3 to look like:

'1': <at> VM:'1': <at> VM:'1': <at> VM:'1': <at> VM:'1'

...and:

SUM(ARRAY3)
(Continue reading)

Charles Stevenson | 24 Jul 2012 14:54
Picon

Re: [U2] Comparing Two Dyamic Arrays

Mike meant  NES( ),  not  EQS( ).
and SUMMATION( ),  not SUM( ).
SUM( ) won't yield a scalar unless all delimiters are the same.

       ResultArray =  NES(Array1, Array2)
       If summation(ResultArray)=0 then samething = true else samething 
= false

Which is all well and good . . . as long as you consider "7" = "7.00" = 
"007" = " 7."
____________

To address Bill Brutzman's original question:

The trouble is that we don't _declare_ variables in UV/UD/MV Basic as 
strings or integer, etc.
So UV & its kin makes a best guess.
UV (& kin? There may be some variance!)  will attempt to compare EQ, NE, 
GT, & their ilk the two vars numerically, if possible.
That's what happens with my "seven" example above.  All those strings 
are treated as equal numerically.
The related multivalue handling functions, .e.g, EQS, do the same, piece 
by piece.

If one of the two vars can't be treated numerically, then it compares as 
strings.

This is probably as good a general solution as any using "EQ":

       if  len(Array1) EQ len( Array2 )  then       ; * because len( )  
(Continue reading)

Wjhonson | 24 Jul 2012 18:42
Picon
Favicon

Re: [U2] Comparing Two Dyamic Arrays


I think you missed the point that UV (and it's kin) do *not* compare all strings numerically if possible.
It entirely depends on which operation you try to use.
That was the example I gave where all the strings are numerically identical and yet the equal test fails.

-----Original Message-----
From: Charles Stevenson <stevenson.chas <at> gmail.com>
To: U2 Users List <u2-users <at> listserver.u2ug.org>
Sent: Tue, Jul 24, 2012 6:21 am
Subject: Re: [U2] Comparing Two Dyamic Arrays

Mike meant  NES( ),  not  EQS( ).
nd SUMMATION( ),  not SUM( ).
UM( ) won't yield a scalar unless all delimiters are the same.
       ResultArray =  NES(Array1, Array2)
      If summation(ResultArray)=0 then samething = true else samething 
 false
Which is all well and good . . . as long as you consider "7" = "7.00" = 
007" = " 7."
___________
To address Bill Brutzman's original question:
The trouble is that we don't _declare_ variables in UV/UD/MV Basic as 
trings or integer, etc.
o UV & its kin makes a best guess.
V (& kin? There may be some variance!)  will attempt to compare EQ, NE, 
T, & their ilk the two vars numerically, if possible.
hat's what happens with my "seven" example above.  All those strings 
re treated as equal numerically.
he related multivalue handling functions, .e.g, EQS, do the same, piece 
y piece.
(Continue reading)

George Gallen | 24 Jul 2012 19:09

Re: [U2] Comparing Two Dyamic Arrays

I second Wil on this one.

I wouldn't expect two dynamic arrays to be equal (using the = operator) unless they
Were EXACTLY the same, since a dynamic array is nothing more than a string variable
With multiple delimiters, so by checking  x = y.

If you want to compare dynamic arrays on an attribute by attribute level maybe UV
Could have a way to say  x<> = y<>  or use the compare function which is what your
Asking...to compare on array against another, vs asking if one array is exactly like
The other.

Which was why I asked about the length's being equal. If the two arrays didn't have
The same length, then don't even bother to ask if they are the same!

I think the confusion is with x=y where x and y are string representing numbers they
Can be equal, but not the same - but once you put a delimiter in that string, all bets
Are off.

George

-----Original Message-----
From: u2-users-bounces <at> listserver.u2ug.org [mailto:u2-users-bounces <at> listserver.u2ug.org] On
Behalf Of Wjhonson
Sent: Tuesday, July 24, 2012 12:42 PM
To: u2-users <at> listserver.u2ug.org
Subject: Re: [U2] Comparing Two Dyamic Arrays

I think you missed the point that UV (and it's kin) do *not* compare all strings numerically if possible.
It entirely depends on which operation you try to use.
That was the example I gave where all the strings are numerically identical and yet the equal test fails.
(Continue reading)

Ed Clark | 24 Jul 2012 19:58

Re: [U2] Comparing Two Dyamic Arrays

There may be a little confusion here too because unidata and some flavors in universe have vector math on by
default, so for example:

001 A=1: <at> AM:3
002 B=2: <at> VM:9
003 CRT A+B

on unidata and universe in information flavor this will print  3]9^3, while universe in ideal or pick flavor
will print 0. So I can see where someone might have an expectation that the = operator will also see vectors,
but it doesn't. you need to use eqs. 

On Jul 24, 2012, at 1:09 PM, George Gallen wrote:

> I second Wil on this one.
> 
> I wouldn't expect two dynamic arrays to be equal (using the = operator) unless they
> Were EXACTLY the same, since a dynamic array is nothing more than a string variable
> With multiple delimiters, so by checking  x = y.
> 
> If you want to compare dynamic arrays on an attribute by attribute level maybe UV
> Could have a way to say  x<> = y<>  or use the compare function which is what your
> Asking...to compare on array against another, vs asking if one array is exactly like
> The other.
> 
> Which was why I asked about the length's being equal. If the two arrays didn't have
> The same length, then don't even bother to ask if they are the same!
> 
> I think the confusion is with x=y where x and y are string representing numbers they
> Can be equal, but not the same - but once you put a delimiter in that string, all bets
> Are off.
(Continue reading)


Gmane