#REDIRECT (change source file) 

Top  Previous  Next

 

#REDIRECT( [file] )

#REDIRECT

Changes the current generated source destination file.

file

A string constant, template symbol, or expression containing a DOS file specification that has already been opened with #OPEN or #CREATE. This may be a fully qualified DOS pathname. If omitted, the source generation destination returns to the previous file that received generated source.

The #REDIRECT statement changes the destination file for generated source code. All source generation output is directed to the specified file until a #OPEN or another #REDIRECT statement is executed. If the file has not been previously opened (or created), or is closed, then a source generation error is produced.

The destination files for generated source are kept as a LIFO (Last In, First Out) "stack" list. When #REDIRECT is issued without a file parameter, the source generation destination reverts to the previous destination file.

Example:

#SET(%NewProgramFile,(%Application & '.CLW'))    #!Temp new program filename

#CREATE(%NewProgramFile)                         #!Create new program file

#FOR(%Module)

 #CREATE(%Module & '.CLW')                      #!Make module files

#ENDFOR

#REDIRECT(%NewProgramFile)                       #!Redirect output to program file

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

#CLOSE(%NewProgramFile)                          #!Create new program file

#FOR(%Module)

#REDIRECT(%Module & '.CLW')                    #!Redirect output to module file

 #GENERATE(%Module)                             #!Generate module header

 #FOR(%ModuleProcedure)                         #!For all procs in module

   #FIX(%Procedure,%ModuleProcedure)            #!Fix current procedure

   #GENERATE(%Procedure)                        #!Generate procedure code

 #ENDFOR                                        #!EndFor all procs in module

#ENDFOR

#!The following code demonstrates the LIFO files list:

#REDIRECT('F1.CLW')                              #!List contains:   F1

#REDIRECT('F2.CLW')                              #!List contains:   F1,  F2

#REDIRECT('F3.CLW')                              #!List contains:   F1,  F2,  F3

#REDIRECT( )                                     #!List contains:   F1,  F2

#REDIRECT( )                                     #!List contains:   F1