Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to check ASCII in a string

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
bittu
Warnings : 1

New User


Joined: 07 Jan 2007
Posts: 19
Location: Bangalore

PostPosted: Thu Sep 18, 2008 12:12 pm    Post subject: How to check ASCII in a string
Reply with quote

Hi,

How do we check whether a string contains all ASCII characters in a COBOL program?

Thanks
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10232
Location: italy

PostPosted: Thu Sep 18, 2008 12:36 pm    Post subject: Reply to: How to check ASCII in a string
Reply with quote

in standard/old ascii only values 000-127 are valid
in extended ascii all 256 bit configurations are valid

the best approximation You can have,
according to encoding convention, is to find out if the string is printable
but as usual You have to express Your requirement better
Back to top
View user's profile Send private message
bittu
Warnings : 1

New User


Joined: 07 Jan 2007
Posts: 19
Location: Bangalore

PostPosted: Thu Sep 18, 2008 1:17 pm    Post subject: Reply to: How to check ASCII in a string
Reply with quote

Thanks to all.
Below is the explaination abt this requirement:
I need to read a value in to a Working storage variable from an input file. How do I check whether the value(say "FRANCE") in the variable is made up of ASCII charcaters?

Thanks
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8001
Location: Bellevue, IA

PostPosted: Thu Sep 18, 2008 5:09 pm    Post subject:
Reply with quote

I think some real thought needs to be given to this requirement. For example, you have a variable that has one character in it; that character's hexadecimal value is 4E (78 decimal). In EBCDIC that is a plus sign but in ASCII it is an upper case N. Which way you refer to it depends on how you want to use it -- there is absolutely no inherent meaning to the character.

So in general, you cannot tell automatically if a given variable has EBCDIC or ASCII data in it since each character represents BOTH an ASCII value as well as an EBCDIC value. If I see a batch of hex '40' values in the variable I'm going to suspect EBCDIC whereas a batch of hex '20' values means I'm going to be thinking ASCII -- but I've seen cases where both of those assumptions are wrong.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Sep 18, 2008 8:59 pm    Post subject:
Reply with quote

Hello,

Quote:
How do we check whether a string contains all ASCII characters in a COBOL program?
If you are reading from an "input file", it is more than 99% likely that you are reading ebcdic characters.

The most common way i've seen ascii characters in a file read on the mainframe is when someone made a mistake transferring the file to the mainframe. They sent the file in binary causing the resulting data to still be in ascii. Whenever this happened, the file transfer is correct so that the resulting data is ebcdic on the mainframe.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Check Binary Values for symbols gandikk CA Products 3 Tue Mar 21, 2017 5:11 am
No new posts Replacing same string with different ... vickey_dw DFSORT/ICETOOL 6 Wed Feb 22, 2017 10:44 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 7 Fri Nov 18, 2016 1:48 pm
No new posts Check System time(Minute) Using TIME1... balaji81_k DFSORT/ICETOOL 5 Fri Nov 11, 2016 10:53 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us