View previous topic :: View next topic
|
Author |
Message |
Vishwamurthy
New User
Joined: 11 Mar 2008 Posts: 57 Location: India
|
|
|
|
Dear all,
How do I write a User-defined class in COBOL?
As in
if a is alphabetic then display 'good name'
but unfortunately,
name generally has a '.' also as in 'Mac. Gillan'
in this case, i would like to code
if a is name-like then display 'good name'
where name-like is a user-defined class which includes '.' and alphabets |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
How do I write a User-defined class in COBOL? |
One way would be to define an 88-level and mention all of the acceptable values for a byte. In the code loop thru the name field comparing the current byte against the 88-level. |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
If you use the "class-name" (mentioned in the posted link) or an 88, be aware that you should not code "A" thru "Z". There are values in that range that are not values you would consider acceptable. . .
For capital letters you would use "A" thru "I", "J" thru "R", and "S" thru "Z".
I'll let you research the lower case letters |
|
Back to top |
|
|
Vishwamurthy
New User
Joined: 11 Mar 2008 Posts: 57 Location: India
|
|
|
|
Thanks all
Please educate me the difference between
"A" thru "Z"
and
"A" thru "I", "J" thru "R", and "S" thru "Z" |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
The EDCDIC collating sequence defines upper-case letters in interspersed groups of 9, 9 and 8.
For example, an upper-case "A" is a hex X'C1' and an upper-case "I" is a hex X'C9'.
Continuing, an upper-case "H" is a X'D1' and an upper-case "R" is a X'D9' and so-on and so-on.
If you check for "A" through "Z", then you'll also be including bogus hex-values (IE: X'CA' through X'D0'), which may raise a false positive.
The easiest way to check for capital "A" through "Z", would be to use -
IF ALPHABETIC and NOT = SPACE test clause.
This same collating sequence applies to lower-case letters as well.
Regards, |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Keeping in mind that the "." (period) and possibly some other characters may be valid in the name as well. . . |
|
Back to top |
|
|
Vishwamurthy
New User
Joined: 11 Mar 2008 Posts: 57 Location: India
|
|
|
|
I am unable to use the method suggested. Please look at the COBOL Program i have written in the following link/photo
Image/link removed. . |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
As you probably noticed, the link/image did not come thru as you intended and has been removed.
Please post code using copy/paste and the "Code" tag for readability. You do not need to post the entire program, only the parts that have to do with this question and any errors encountered. |
|
Back to top |
|
|
|