View previous topic :: View next topic
|
Author |
Message |
kumar_jalluri
New User
Joined: 02 Jun 2005 Posts: 24 Location: PUNE
|
|
|
|
Hi,
I need to verify a string for characters 0 1 2 3 4 5 6 7 8 9 A B C D E F.
If the string is having other than this characters, I have some processing. other wise I have different process.
Could you please let me know how to do it in COBOL
Thanks |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Your first problem is that COBOL does not have strings. COBOL has variables that can be numeric, alphanumeric, national, DBCS ... but never string. Terminology is critical in IT where similar sounding terms may mean very different things -- so you need to use appropriate terminology first.
Assuming you meant an alphanumeric variable, you have two choices:
1) redefine as an array of one-byte variables and check each byte individually.
2) use reference modification to check each individual byte of the variable. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
you could also, within the SPECIAL-NAMES paragraph
use the CLASS clause |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
miss-reading of the manuals is the root cause of this.
string
array
are two examples.
always in the manuals:
string data items refer to java or c items
array is a java-array-object.
yet when the word (string-data-item and java-array-object) is used without
the full qualifier,
people tend to think that it is ok to use the abbreviation to refer to COBOL objects:
noncobol - cobol
string - alphanumeric data item
array - cobol internal table
as with so many other terms (jcl for example),
people tend to use what is convenient for them,
until they try searching on a term that does not exist. |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
just an idea :
Code: |
move invar to testvar
INSPECT Testvar CONVERTING " 0123456789ABCDEF"
TO "X "
if testvar <> spaces
display "error"
end-if |
|
|
Back to top |
|
|
kumar_jalluri
New User
Joined: 02 Jun 2005 Posts: 24 Location: PUNE
|
|
|
|
Thanks... It is working for above logic. |
|
Back to top |
|
|
|