Skip to main content

How to write all program's output (or display) to a file?

  • February 15, 2013
  • 0 replies
  • 0 views

Problem:

How to write all the console output (including errors) from a batch program to a text file?

Resolution:

1) You will need to compile your programs with the CHARACTER option rather

   than GRAPHICAL.  This ensures that any errors are display as plain text

   rather than in a Windows message box.

2) You will need to set the following runtime switches:

   set cobsw=-I2 S5

3) You then run your program with redirection:

   paddy01.exe > x.txt

For example, the following program:

       procedure division.

           display "Before CALL...".

           call "fred".

           display "After CALL...".

           stop run.

The CALL to FRED fails and should generate a 173 error.  The redirection file (x.txt) contains:

Before CALL...

Load error : file 'fred'

error code: 173, pc=0, call=1, seg=0

173     Called program file not found in drive/directory

If this does not give you the functionality you are looking for then we would suggest looking at implementing CBL_ERROR_PROC and/or CBL_EXIT_PROC which will give them much more flexibility.

Old KB# 5279

0 replies

Be the first to reply!