View previous topic :: View next topic
|
Author |
Message |
ashesh choudhury
New User
Joined: 05 May 2008 Posts: 5 Location: mumbai
|
|
|
|
i have a variable say A(6). how can i check whether the value present in the variable is alphanumeric or not? is there any special syntax for that? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
what is A(6)? that is not a variable name or picture clause.
besides, everything is alphanumeric in singlebyte types. |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi ashesh,
Just remember when reading the above thread, that 'A' THRU 'Z' and 'a' THRU 'z' will contain "junk" values.
If you have an IBM "green card" (or whatever its equivalent is these days) it will show you what the ranges need to be to eliminate those "junk" values. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
how can i check whether the value present in the variable is alphanumeric or not |
First, you need to define what are all of the "good" values for a byte (are lower-case letters valid or junk?). Then you need to define any other rules (for example, is an embedded space valid or not?).
Once the rules are defined, you can then implement code to enforce them. If you post all of the rules, we may be able to offer suggestions. |
|
Back to top |
|
|
yogeshwar_ade
Active User
Joined: 31 Aug 2006 Posts: 103 Location: INDIA
|
|
|
|
ashesh choudhury wrote: |
i have a variable say A(6). how can i check whether the value present in the variable is alphanumeric or not? |
Ashesh, if I am not wrong A(6) is your Picture Clause. 'A' is for ALPHABATIC PIC.
You can use SPECIAL-NAME for this one.
Yogeshwar |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Please post your SPECIAL-NAME solution for the posted requirement. |
|
Back to top |
|
|
ashesh choudhury
New User
Joined: 05 May 2008 Posts: 5 Location: mumbai
|
|
|
|
Thanks for your replies.
Actually in the field everything EXCEPT special charecters are allowed.so can anybody provide a way to check whether the field contains any special charecter or not.
for example ,"ABC990' is allowed
but "*-/+@?" is not allowed.
Is there any way for ensuring this? |
|
Back to top |
|
|
yogeshwar_ade
Active User
Joined: 31 Aug 2006 Posts: 103 Location: INDIA
|
|
|
|
dick scherrer wrote: |
Hello,
Please post your SPECIAL-NAME solution for the posted requirement. |
Here it is...
Code: |
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. IBM-370.
OBJECT-COMPUTER. IBM-370.
SPECIAL-NAMES. CLASS VALID-DATA '0' THRU '9'
'A' THRU 'Z'. |
Here VALID-DATA will work as ALPHANUMERIC CLASS, will check ALPHABETIC & NUMERIC values. If you want to add SPACES or any other symbol, you can add these to your VALID-DATA class.
Here, we are defining our own CLASS VALID-DATA.
We can use VALID-DATA as 'IS VALID-DATA' condition, similar of 'IS NUMERIC' check.
Code: |
IF VARIABLE-NAME IS VALID-DATA
NEXT SENTENCE
ELSE
DISPLAY "VARIABLE-NAME is not ALPHANUMERIC".
|
Correct me If I am wrong.
Yogeshwar |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
does defining the class as A thru Z,
will this define the value range as: x'C1' thru x'E9'
or as: x'C1' thru x'C9', x'D1' thru x'D9' and x'E1' thru x'E9'? |
|
Back to top |
|
|
yogeshwar_ade
Active User
Joined: 31 Aug 2006 Posts: 103 Location: INDIA
|
|
|
|
Characters A thru Z are not contiguous.There are a few printables in there, like "\" AND "}" To be safe you should code it:
Code: |
'A' THRU 'I' 'J' THRU 'R' 'S' THRU 'Z'
|
For more help on SPECIAL-NAMES have a look on
This Thread |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
Correct me If I am wrong. |
Yes, you are wrong. . . Your example allows characters that should not be allowed.
Quote: |
Actually in the field everything EXCEPT special charecters are allowed |
What about hex values that are not on the keyboard? I suspect those too should be rejected.
Look at my earliest post - you need to define exactly which characters are "good" and if there are any rules beyond a single-character validation. It is time to actually do the specification, not talk in generalaties. Once the specifics, some generalization is probably possible (i.e. A-I, etc). As has been mentioned A-Z is not correct. |
|
Back to top |
|
|
yogeshwar_ade
Active User
Joined: 31 Aug 2006 Posts: 103 Location: INDIA
|
|
|
|
yogeshwar_ade wrote: |
Characters A thru Z are not contiguous.There are a few printables in there, like "\" AND "}" To be safe you should code it:
Code: |
'A' THRU 'I' 'J' THRU 'R' 'S' THRU 'Z'
|
|
Thanks D for correcting me. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
Thanks D for correcting me. |
You're welcome, but i'd not have included that bit if i'd seen your earlier correction when i replied. Seems like a bit of strange magic. . .
Sorry for the overdose
Hopefully, TS has what is needed to implement the required code. |
|
Back to top |
|
|
|