View previous topic :: View next topic
|
Author |
Message |
anil_jdh
New User
Joined: 05 Apr 2006 Posts: 4
|
|
|
|
A COBOL program is reading a file and printing it but the file contains some nonprintable characters. How to locate those nonprintable characters and replace them with spaces. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
anil_jdh wrote: |
A COBOL program is reading a file and printing it but the file contains some nonprintable characters. How to locate those nonprintable characters and replace them with spaces. |
You have three possibilities:
You know what the unprintable character is but not where;
You know where the unprintable character is but not what;
You don't know where or what the unprintable character is.
The first case is a simple INSPECT CONVERTING and the second is a simple move. The third will need a byte-by-byte scan thru the data testing every byte for "printableness" or "unprintableness".
Have fun.... |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
If you can look at the file in tso/browse or view, you can find the "unprintable" characters by typing "find p'.' " in the command area and pressing enter. The editor will move the sursor from one unprintable character to the next.
If the file is too large to look at, use a utility to create a small set of the data and then look at that.
Once you know what kind of "unprintables" you are dealing with, you can code for them. |
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
Wouldn't one just need to check for data transparency? |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
superk wrote: |
Wouldn't one just need to check for data transparency? |
Yes, sure..... BTW, what means "data transparency" and how would I do it? |
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
When EBCDIC data is transparent (i.e. non-displayable), it contains hex values less than a blank (x'40'). I guess I was wondering if each byte of data could be checked for a hex value < x'40', and then translated to x'40' if detected. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
There are also the 'unprintable' values above x'40' - for example x'61' or x'AA' or x'FE' etc. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
This solution might be a little tedious, but it should work fine. Using the link below create an INSPECT stmt with a sending string that contains the hex values of each non-displayable char you want to replace with a space.
The hex values you can get from the link below, for e.g.:
The chart shows that X'00' thru X'39', X'80', X'90', X'9A thru X'A0', and so on are not displayable. You would have to code the INSPECT stmt something like this:
INSPECT YOUR-REC CONVERTING X'00010203...3980909A9B9C...9E9FA0...' TO 'bbb...bbbb...'
The (...) above exposes my laziness [you'll have to fill in the (...) and the blanks (b)]. Note that the number of blanks coded in the receiving field must EQUAL the number of 2 digit hex values coded in the sending field.
BTW, you can use X'4040...40' in the receiving field. Also, don't use a variable to define the fields, make them in-line literals; it's much more efficient (only one assembler instr).
You can also blank any obscure printables from the record.
publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/handheld/Connected/BOOKS/IGY3LR10/APPENDIX1.3.1 |
|
Back to top |
|
|
|