Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DISPLAY problem on OpenVMS (newbie problem)

Status
Not open for further replies.

JarlH

Programmer
Jul 26, 2002
365
SE
I have a few hundred Cobol programs writing output using DISPLAY. E.g.[tt]
DISPLAY "COMMIT WORK"[/tt]

The Cobol files are compiled like[tt]
$ COB/ANSI/NOLIST/DISPLAY_FORMATTED xyz.cob[/tt]

The programs are producing simple log files, e.g.:
[tt]
$ DEFINE/USER SYS$OUTPUT xyz_log.dat
$ RUN MM$$EXEC:xyz
[/tt]

When I do "type xyz_log.dat" it looks just fine on the screen:[tt]
CL_STANDARD
TABLE728a
TAB734
CTS1.CL_DATA_TYPE
COMMIT WORK[/tt]

But if I open the file in emacs it looks like:[tt]
CL_STANDARD^M
TABLE728a^M
TAB734^M
CTS1.CL_DATA_TYPE^M
COMMIT WORK^M[/tt]

As you can see the file has an extra [tt]^M[/tt] at end of each line.

Is there a simple way to get rid of these characters?
 
Use a dos to unix file conversion tool.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Sorry if my posting was a bit vague, but what I meant was if it's possible to create the (original) log files without those [tt]^M[/tt]s.

For example a compiler switch or DISPLAY trick.
 
which cobol compiler version ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
^M is probably the Carriage Return character, i.e. ASCII-character number 015 or 0x0D

You can quickly remove these characters using a tool like sed or a script language like rexx, perl, python, java,...

Have you something from the above tools/languages on your system? (I have seen last time VAX VMS about 15 years ago, so I don't know what's on the Box)

For example here is the Rexx-ish way a script named remove_ctrl_m.rex

Code:
[COLOR=#0000ff]/************************************************************************* [/color]
[COLOR=#0000ff]   Program name: [/color]
[COLOR=#0000ff]     remove_ctrl_m.rex     [/color]
[COLOR=#0000ff]   Purpose: [/color]
[COLOR=#0000ff]     Removing Ctrl_M character from a file   [/color]
[COLOR=#0000ff]   Usage:[/color]
[COLOR=#0000ff]     rexx remove_ctrl_m.rex < file_with_ctrlm.txt > file_without_ctrlm.txt[/color]
[COLOR=#0000ff]**************************************************************************/[/color]

[COLOR=#0000ff]/* define Ctrl_M */[/color]
Ctrl_M  [COLOR=#804040][b]=[/b][/color][COLOR=#ff00ff]"0D"x[/color]

[COLOR=#804040][b]do[/b][/color][COLOR=#804040][b] while [/b][/color][COLOR=#008080]lines()[/color] [COLOR=#804040][b]\=[/b][/color] 0
  [COLOR=#804040][b]parse linein[/b][/color] line
  [COLOR=#0000ff]/* removing "0D"x from mystring */[/color]
  line [COLOR=#804040][b]=[/b][/color] [COLOR=#008080]changestr([/color]Ctrl_M[COLOR=#804040][b],[/b][/color] line[COLOR=#804040][b],[/b][/color] [COLOR=#ff00ff]""[/color][COLOR=#008080])[/color]
  [COLOR=#804040][b]say[/b][/color] line
[COLOR=#804040][b]end[/b][/color]

Usage example:

Given an example file named file_with_ctrlm.txt, which every line is ending with ^M
Code:
line1[COLOR=red]^M[/color]
line2[COLOR=red]^M[/color]
line3[COLOR=red]^M[/color]
Then after running the above script with
Code:
rexx remove_ctrl_m.rex < file_with_ctrlm.txt > file_without_ctrlm.txt
you will get a file named file_without_ctrlm.txt
Code:
line1
line2
line3
 
^M is a carrage return, ascii 13. Most non-Unix style systems end a record with CR LF. Unix style systems end a record with LF only. I guess emacs is a Unix style system. Earlier posts suggest ways to get rid of the CR. I don't think there is any way to avoid generating it. If you use the COBOL syntax ADVANCING 0, it generates a CR without the LF.
 
Yes CR is ASCII-character number 13 (decimal) or 015 (octal) or 0x0D (hexadecimal) :)

I have problem with ^M in other case:
When I run some SQL-queries using iSeries Navigator and then I save the queries in a text file and if I open then the same text-file with vim (editor), it shows me every line ending with ^M. Then when I examine that file in hexadecimal view, I see that every line is ending with 3 hex characters: 0D 0D 0A. These are the characters CR CR LF (CR - Carriage Return, LF - LineFeed)

But this is not very big issue - Simply remove the ^Ms in your favorite editor and when there are too much lines, then write a simple script (as I showed above for example in REXX) in your favorite scripting language which does the work for you.

I looked at ADVANCING 0 in my COBOL-manual, but have found nothing in context with DISPLAY. I have found only DISPLAY WITH NO ADVANCING with this description
DISPLAY WITH NO ADVANCING statement
By using the NO ADVANCING phrase on the DISPLAY statement, you have the capability to leave the cursor following the last character that is displayed. This allows you to string together items to be displayed on a single line from various points in the ILE COBOL program.
which IMHO doesn't help to solve this issue.
 
What about this ?
DISPLAY "COMMIT WORK" x"0A" WITH NO ADVANCING

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks for all replies!

Seems like converting the log files is the (only) way to go.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top