User Tools

Site Tools


open_open_source_file_.htm
Navigation:  Templates > Template Language Reference > Complete Alpha Listing >====== #OPEN (open source file) C6H0068.jpg ====== Previous pageReturn to chapter overviewNext page

#OPEN( file ) [, READ ]

blk2blue.jpg

#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

open_open_source_file_.htm.txt · Last modified: 2021/04/15 15:57 (external edit)