Writing an output file to a directory or to a file whose name uses spaces
Problem:
In Mainframe Express, when writing an output file to a directory name that contained spaces, no error messages were issued and the file was not written as expected.
Resolution:
Mainframe Express allows use of the Non-mainframe dialect dialect(mf), (Spacey file names are described in the documentation in Chapter 3. Filenames under file organizations > dynamic assignments). Writing output files to a directory structure name or filename that contains spaces.
For example, if the output file is to be written to:
c:\\Program Tests\\Micro Focus\\Mfuser\\file4.datthen that directory structure must be enclosed within quotation marks. And it would be referenced as:
"""c:\\Program Tests\\Micro Focus\\Mfuser\\file4.dat"""If the new file is to be written to the current directory so only the filename is used, then the filename must be enclosed within quotation marks. For example, if the output file is to be written as:
My Test File.Datthen it would be referenced as:
"""My Test File.Dat"""A sample program is included below to show means of writing output files to a directory structure and to a filename that contain spaces.
'''user1 test area\\File1.Txt'''
instead of this:
"""user1 test area\\File1.Txt"""
then a file named: 'user1 will be created and no errors will be issued. The compiler treats the space as a delimiter.
Sample Program:
Identification Division. Program-Id. LORINCE. * This program illustrates writing output files to * a spacey directory structure and to a spacey filename. * The directories C:\\Test T1234567 and C:\\Program Tests * must be defined (or something similar to them and this * program changed accordingly). Or one can define the * sub-directories 'user1 test area' and 'user2 test area' * to test this from any directory or drive of your choice. * The program must be compiled using a Non-Mainframe * dialect when being used under Mainframe Express. This is * the same as specifying DIALECT(MF) from a command line. * * The command to test this from a MFE Command Prompt would be: * cobol lorince dialect(mf) anim noobj outdd(out.txt) * initcall(cbl_debugbreak) list() setting(col3) * rawlist copylistcomment(7) refno; * run lorince * When placed into a .BAT file the string from 'cobol' to * the terminating semi-colon ';' should be on one line. * The 'run pgmname' is on a separate line. * When the program runs a prompt will be issued asking * whether or not one wants to start a debug session. Environment Division. Input-Output Section. File-Control. Select FileOneOutput Assign to FileOnePath Organization is Line sequential File Status is Fs1. Select FileTwoOutput Assign to FileTwoPath Organization is Line sequential File Status is Fs2. Data Division. Fd FileOneOutput. 1 Rec1Data Pic X(256). Fd FileTwoOutput. 1 Rec2Data Pic X(256). Working-Storage Section. 1 FileOnePath Pic X(50) Value * """C:\\Test T1234567\\Micro Focus\\Mfuser\\File1.Txt""". * """user1 test area\\File1.Txt""". """user1 test area\\My Test File1.Txt""". 1 FileTwoPath Pic X(50) Value * """C:\\Program Tests\\Micro Focus\\Mfuser\\File2.Txt""". * """user2 test area\\File2.Txt""". """user2 test area\\My Test File2.Txt""". 1 WsFile1Text Pic X(20) Value 'This is in File One'. 1 WsFile2Text Pic X(20) Value 'This is in File Two'. 1 FileStats. 2 Fs1. 3 Fs11 Pic 9(1). 3 Fs12 Pic 9(1). 3 Fte Redefines Fs12 Pic 99 Comp-X. 2 Fs2. 3 Fs21 Pic 9(1). 3 Fs22 Pic 9(1). 3 Fte Redefines Fs22 Pic 99 Comp-X. Procedure Division. P1. Open Output FileOneOutput If Fs1 <> Zero Display 'FILE1 OPEN ERROR ' End-If Open Output FileTwoOutput If Fs2 <> Zero Display 'FILE2 OPEN ERROR ' End-If Write Rec1Data From WsFile1Text If Fs1 <> Zero Display 'FILE1 WRITE ERROR ' End-If Write Rec2Data From WsFile2Text If Fs2 <> Zero Display 'FILE2 WRITE ERROR ' End-If Close FileOneOutput If Fs1 <> Zero Display 'FILE1 CLOSE ERROR ' End-If Close FileTwoOutput If Fs2 <> Zero Display 'FILE2 CLOSE ERROR ' End-If Goback.
Sample .BAT file for testing:
cobol lorince dialect(mf) anim noobj outdd(out.txt) initcall(cbl_debugbreak) list() setting(col3) rawlist copylistcomment(7) refno;
run lorince
Incident Number: 2257729
output file write long spacey names directory non-mainframe
Date: Name: Description of change: Date: Name: Description of change:
#RMCOBOL
#Enterprise
#COBOL
#MFDS
#AcuCobol
#EnterpriseDeveloper
#ServerExpress
#MainframeExpressandMFE
#netexpress