#OPEN (open source file) 

Top  Previous  Next

 

#OPEN( file ) [, READ ]

#OPEN

Opens a disk file to receive generated source code.

file

A string constant, template symbol, or expression containing a DOS file specification. This may be a fully qualified DOS pathname.

READ

Opens the file as read-only. The file cannot be already open for output.

The #OPEN statement opens a disk file to receive the source code generated by #GENERATE. If the file does not exist, it is created. If the file already exists, it is opened in "append source" mode. If the file is already open, a source generation error is produced.The file is automatically selected as the active source output destination.

If the READ attribute is present, the file is opened in read-only mode so the #READ statement can read it as an ASCII text file. Only one file can be open for input at one time.

Example:

#SET(%ProgramFile,(%Application & '.$$$'))       #!Temp program filename

#OPEN(%ProgramFile)                              #!Open existing program file

#GENERATE(%Program)                              #!Generate main program header

#CLOSE(%ProgramFile)                             #!Close output file

 

#OPEN(%ProgramFile),READ                         #!Open it in read-only mode

#DECLARE(%ASCIIFileRecord)

#LOOP

 #READ(%ASCIIFileRecord)

#! Parse the line and do something with it

#IF(%ASCIIFileRecord = %EOF)

 #BREAK

#ENDIF

#ENDLOOP

#CLOSE(%ProgramFile),READ

 

See Also:     #READ ,#CLOSE