×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

DISPLAY problem on OpenVMS (newbie problem)

DISPLAY problem on OpenVMS (newbie problem)

DISPLAY problem on OpenVMS (newbie problem)

(OP)
I have a few hundred Cobol programs writing output using DISPLAY. E.g.
             DISPLAY "COMMIT WORK"
   

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


The programs are producing simple log files, e.g.:

$ DEFINE/USER SYS$OUTPUT xyz_log.dat
$ RUN MM$$EXEC:xyz


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


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


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

Is there a simple way to get rid of these characters?
 

RE: DISPLAY problem on OpenVMS (newbie problem)

(OP)
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 ^Ms.

For example a compiler switch or DISPLAY trick.

RE: DISPLAY problem on OpenVMS (newbie problem)

^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

/*************************************************************************
   Program name:
     remove_ctrl_m.rex     
   Purpose:
     Removing Ctrl_M character from a file   
   Usage:
     rexx remove_ctrl_m.rex < file_with_ctrlm.txt > file_without_ctrlm.txt
**************************************************************************/

/* define Ctrl_M */
Ctrl_M  ="0D"x

do while lines() \= 0
  parse linein line
  /* removing "0D"x from mystring */
  line = changestr(Ctrl_M, line, "")
  say line
end

Usage example:

Given an example file named file_with_ctrlm.txt, which every line is ending with ^M

CODE

line1^M
line2^M
line3^M
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

RE: DISPLAY problem on OpenVMS (newbie problem)

(OP)

Quote (PHV):


which cobol compiler version ?

HP COBOL V2.8

RE: DISPLAY problem on OpenVMS (newbie problem)

^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.

RE: DISPLAY problem on OpenVMS (newbie problem)

Yes CR is ASCII-character number 13 (decimal) or 015 (octal) or 0x0D (hexadecimal) smile

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

Quote:


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.

RE: DISPLAY problem on OpenVMS (newbie problem)

(OP)
Thanks for all replies!

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

 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close