![]() | ![]() | ![]() | ![]() | ![]() |
In most situations you would read one or more input files to generate a single output file. There are situations where you'd like more control so that you can generate multiple files.
You can nest to any level as only one output file is open at any time so file resources are not wasted.
[WhiteSpace]#output ["]OutputName["] [AsIs] [Append] [HTML|REXX|OTHER]
If "AsIs" was specified then the "OutputName" specifies the name of the output file otherwise the value is passed through the output specification provided with the "/Output" switch. If the "OutputName" parameter is not specified at all then the previous output file is restored.
Note that files specified for use "AsIs" do not have their case adjusted as specified on the /FileNames switch, if you require the case to be adjusted you will need to make use of the EnsureFileHasCorrectCase routine.
If "Append" was specified then the output file is not deleted if it already exists.
In some circumstances you may wish to generate a new file in a different processing mode to the current one, if this applies to you then choose on of "HTML", "REXX" or "OTHER".
When a previous file is restored (no parameters) then new data is appended, otherwise the file is erased before writing the first line.
Line 1 of file 1 Line 2 of file 1 #output '2nd' Line 1 of file 2 Line 2 of file 2 #output 'c:\path\3nd.ext' AsIs Line 1 of file 3 #output Line 3 of file 2 #output Line 3 of file 1
The following example show how you can calculate filenames which are relative to the directory where output normally goes (as determined by the /OUTPUT switch:
;--- Macro to calculate filename relative to output directory --------------- #evaluate "" ^OutputDir = EnsureFileHasCorrectCase(_filespec('location', '<?OutputFile>'))^ ;;Only need to determine once! #define FileRelativeToOutputDir <??OutputDir>{$File} ;--- Test macro ------------------------------------------------------------- InOutput.OUT = <$FileRelativeToOutputDir FILE="InOutput.OUT"> SubDir\InOutput.OUT = <$FileRelativeToOutputDir FILE="SubDir\InOutput.OUT"> ..\Parents.OUT = <$FileRelativeToOutputDir FILE="..\Parents.OUT">
There may be time when you wish to drop some lines, for example you might be processing a file in a number of passes, this shows how you can do this under windows and OS/2:
#output "NUL" ASIS APPEND ;;Drop output! This line gets dropped #output ;;Stop dropping output!
![]() | ![]() | ![]() | ![]() | ![]() |