| **Navigation:**  [[templates.htm|Templates]] > [[tlrcontents.htm|Template Language Reference]] > Complete Alpha Listing >====== #OPEN (open source file) {{c6h0068.jpg|C6H0068.jpg}} ====== | [[ module module area .htm|{{btn_prev_n.gif|Previous page}}]][[tlrcontents.htm|{{btn_home_n.gif|Return to chapter overview}}]][[ pdefine add pragma to project.htm|{{btn_next_n.gif|Next page}}]] | | || **#OPEN(** //file// **) **[, **READ **] {{blk2blue.jpg|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 read one line of a source file .htm|#READ]] ,[[ close close source file .htm|#CLOSE]]