View previous topic :: View next topic
|
Author |
Message |
Ruchita Jain
New User
Joined: 12 Sep 2013 Posts: 4 Location: ABCD
|
|
|
|
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 |
|
|
sureshpathi10
Active User
Joined: 03 May 2010 Posts: 154 Location: Kuala Lumpur
|
|
|
|
Hi Ruchita,
Could you provide the code you've tried? |
|
Back to top |
|
|
sureshpathi10
Active User
Joined: 03 May 2010 Posts: 154 Location: Kuala Lumpur
|
|
|
|
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 |
|
|
TheMFKid
New User
Joined: 20 Nov 2013 Posts: 91 Location: India
|
|
|
|
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 |
|
|
Ruchita Jain
New User
Joined: 12 Sep 2013 Posts: 4 Location: ABCD
|
|
|
|
Thank you , I performed some hit and trial , variable2 is coming from file so was picking spaces too, solved the issue |
|
Back to top |
|
|
TheMFKid
New User
Joined: 20 Nov 2013 Posts: 91 Location: India
|
|
|
|
Great!. Trace functionality in REXX always help in such cases. |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
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 |
|
|
|