View previous topic :: View next topic
|
Author |
Message |
prodigy
New User
Joined: 15 May 2006 Posts: 28
|
|
|
|
i have a variable which has some string (ex:- 12345WE)
can anybody tell me a way How to check whether the last 2 characters of this string is ALPHANUMERIC or not.. (ex:- 12345WE) |
|
Back to top |
|
|
sunnyk
New User
Joined: 20 Oct 2004 Posts: 59
|
|
|
|
By using Reference modification, move the last two chars to a new working storage variable and then check whether that new variable is > spaces. If yes, then last two chars of the string is ALPHANUMERIC else not.
Regds
Sunny |
|
Back to top |
|
|
venkatm99
New User
Joined: 01 Jun 2006 Posts: 23 Location: Sinagpore
|
|
|
|
hi
suppose alpha numeric varible length is 10 bytes.
01 ws-alpha pic x(10).
01 ws-alpha-r redefines ws-alpha.
05 ws-alpha-1 pic x(08).
o5 ws-alpha-2 pic 9(02).
If ws-alpha-2 is nureric
perform x
else
perform y
end-if
Hope it will clear ur doubt
cheers
venkat |
|
Back to top |
|
|
prodigy
New User
Joined: 15 May 2006 Posts: 28
|
|
|
|
Hey thx guys for ur replies.... was useful |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
It's amazing how these "simple" ques can get complicated. Prodigy asked if you can test that the last 2 chars of a field are alphanuneric, but his example shows the last 2 chars as alphabetic.
Does he mean A or AN. My guess is that he meant A, else he would have used something like W6 as his last 2 chars. Also does he consider a space an alpha; the alpha class test does.
Anyway, I'd try:
Code: |
IF HIS-FLD(n:2) IS NOT ALPHABETIC
OR
HIS-FLD(n:1) = SPACE
OR
HIS-FLD(n + 1:1) = SPACE
DISPLAY 'FIELD IS NOT ALPHA AND/OR CONTAINS SPACES'
ELSE
DISPLAY 'FIELD LOOKS OK TO ME'
END-IF
|
|
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
It gets even more complicated if the last 2 chars are not always in the same place.
The given example was '- 12345WE'. Now what happens if the value is '- 123WE' ?
Can this happen? |
|
Back to top |
|
|
|