IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search Log in to check your private messages Log in
 

Rexx , string comparison through variables


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

New User


Joined: 12 Sep 2013
Posts: 4
Location: ABCD

PostPosted: Wed Jan 08, 2014 11:22 am
Reply with quote

Working on a Rexx program , I am trying to compare two variables containg value as a single alphabet , its not working , when I display values of the two variables they are same. like : Variable1 = A , Variable2 = A
If Variable1 = A (its working )
but if i give Variable1 = Variable2 ( It does not work )

I have initailised both variables at the start of my Rexx program.
variable1 I take as input from user (PULL Variable1) and Variable2 I read from file.
Please advise , thank you.
Back to top
View user's profile Send private message
sureshpathi10

Active User


Joined: 03 May 2010
Posts: 154
Location: Kuala Lumpur

PostPosted: Wed Jan 08, 2014 11:28 am
Reply with quote

Hi Ruchita,

Could you provide the code you've tried?
Back to top
View user's profile Send private message
sureshpathi10

Active User


Joined: 03 May 2010
Posts: 154
Location: Kuala Lumpur

PostPosted: Wed Jan 08, 2014 11:38 am
Reply with quote

You may try using this built-in function,

Code:

COMPARE(string1, string2[, pad])

    returns "0" if "string1" and "string2" are identical
    otherwise, returns the position of the first character that does not match
Back to top
View user's profile Send private message
TheMFKid

New User


Joined: 20 Nov 2013
Posts: 91
Location: India

PostPosted: Wed Jan 08, 2014 1:16 pm
Reply with quote

If Variable1 & Variable2 has the same string, IF VARIABLE1 = VARIABLE2 condition should work independent of whether you are getting the values from console or file.
We will be able to help if you provide your REXX code with TRACE ON.
Back to top
View user's profile Send private message
Ruchita Jain

New User


Joined: 12 Sep 2013
Posts: 4
Location: ABCD

PostPosted: Wed Jan 08, 2014 6:02 pm
Reply with quote

Thank you , I performed some hit and trial , variable2 is coming from file so was picking spaces too, solved the issue icon_surprised.gif
Back to top
View user's profile Send private message
TheMFKid

New User


Joined: 20 Nov 2013
Posts: 91
Location: India

PostPosted: Thu Jan 09, 2014 9:29 am
Reply with quote

Great!. Trace functionality in REXX always help in such cases.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Thu Jan 09, 2014 11:05 pm
Reply with quote

Here's a good example of why we require that querents produce the actual code, enclosed in Code tags.
Code:
/* Rexx */                               
  v1 = "A"                               
  v2 = "A "                             
                                         
  if (v1=v2) then                       
    say "V1 is equal to V2"             
  else                                   
    say "V1 is not equal to V2"         
                                         
  if (v1==v2) then                       
    say "V1 is strictly equal to V2"     
  else                                   
    say "V1 is not strictly equal to V2"
                                         

Note that v1 is equal,, but not strictly equal, to v2.
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
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Forum Replies
No new posts Calling Assembler from REXX PL/I & Assembler 5
No new posts REXX/CLIST tool for BCSR and EDSR CLIST & REXX 2
No new posts Need to split single line into two li... DFSORT/ICETOOL 7
No new posts Calling Rexx program from Cobol CLIST & REXX 12
No new posts Group comparison/update between two f... DFSORT/ICETOOL 10

Back to Top