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

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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
Search our Forums:

Back to Top