IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Compare two character variables Head Scratcher


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Harold Barnes

New User


Joined: 27 Oct 2015
Posts: 33
Location: United States

PostPosted: Fri Aug 28, 2020 12:38 am
Reply with quote

Can someone explain why the 9 characters compare not equal (correct) but the 10 characters compare is neither equal or not equal?


/* REXX */
trace o
/*
en = "1000000464"
xs = "1000000468"
*/

en = "100000464"
xs = "100000468"

if en ¬= xs then
do
say "Not Equal"
exit -1
end

if en == xs then
do
say "equal"
exit 0
end

say "exit 99"
exit 99

vs


/* REXX */
trace o

en = "1000000464"
xs = "1000000468"

/*
en = "100000464"
xs = "100000468"
*/

if en ¬= xs then
do
say "Not Equal"
exit -1
end

if en == xs then
do
say "equal"
exit 0
end

say "exit 99"
exit 99
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1424
Location: Bamberg, Germany

PostPosted: Fri Aug 28, 2020 3:16 am
Reply with quote

See default for DIGITS. Try your code again with adding:
Code:
NUMERIC DIGITS 10

to see the difference.

PS: Change == to =
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1424
Location: Bamberg, Germany

PostPosted: Fri Aug 28, 2020 3:30 am
Reply with quote

To compare strings, use the compare() function.

Code:
if compare(en,xs)¬=0 then say "Not Equal"; else say "Equal"
Back to top
View user's profile Send private message
Harold Barnes

New User


Joined: 27 Oct 2015
Posts: 33
Location: United States

PostPosted: Fri Aug 28, 2020 4:46 am
Reply with quote

It has to do with non-strict compares.
I switched to strict compares and now it works as expected.
Time to get enlightened about strict compares.
Back to top
View user's profile Send private message
View previous topic : : View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Compare the member of two pds on las... DFSORT/ICETOOL 13
No new posts Substitution of JCL variables CLIST & REXX 10
No new posts JCL sort to compare dates in two file... DFSORT/ICETOOL 2
No new posts Repeat n times by substuting SEQNUM i... DFSORT/ICETOOL 2
No new posts Preserve changes to ISPF Panel Variables TSO/ISPF 5
Search our Forums:


Back to Top