**CIGAL Reference Manual, Chapter 1 (Topics): redirect** ===== Redirect -- Redirecting Printed Output ===== CIGAL generates text output in several different output "channels" each of which can be controlled independently. Any one of the channels can be assigned to the special devices, TERMINAL or PRINTER, or to a disk file. Sending output to TERMINAL means it gets printed on the standard computer screen, whereas sending to PRINTER causes the output to be sent over the parallel printer port. CIGAL's standard channels are: Channel Default Device Description ======= ============== =========== OUTPUT TERMINAL All normal output ERROR TERMINAL Error messages JOURNAL inactive A record of every interactive command (see \L[JOURNAL][2]) LOG inactive A copy of all OUTPUT messages sent to the terminal; LOG cannot go to the terminal DEBUG TERMINAL Debugging messages (see \L[DEBUG][4]) You use the OPEN and CLOSE commands to assign a channel to a different device or to a disk file. After assigning a channel with OPEN it remains assigned until it is reassigned or closed (see [[jvs:cigal:manual:chapter2:open|OPEN(2)]] and [[biac:jvs:cigal:manual:chapter2:close|CLOSE(2)]]). CIGAL also recognizes the UNIX (and DOS) convention for redirecting the output of any individual command simply by adding '> target' to the end of the command line. The syntax is: command_line > filename ; write output to FILENAME or: command_line >> filename ; append output to FILENAME or: command_line > printer ; send output to printer or: command_line > terminal ; send output to screen or: command_line > stringvarb ; send output to string variable where COMMAND_LINE is any CIGAL command, EXCEPT an arithmetic expression. Note: If the command line begins with a function, variable, or number, then CIGAL thinks it is an arithmetic expression and will interpret the > or >> as arithmetic operators. To get around this, you should use the TYPE command (see [[jvs:cigal:manual:chapter1:syntax|SYNTAX(1)]] and [[biac:jvs:cigal:manual:chapter2:type|TYPE(2)]]). Note: the > or >> is treated as a separate argument by the parser and therefore MUST have blank spaces before and after it (see [[jvs:cigal:manual:chapter1:syntax|SYNTAX(1)]]). For example, open journal 'logfile' ; these first 2 lines send a copy of open log 'logfile' ; everything you type, and all ; messages printed on the screen ; to LOGFILE. type random(30) ; print 30 numbers on the screen type random(30) > ran.dat ; create disk file named RAN.DAT ; and print the 30 numbers there type vga0(0:11,0:20) >> ran.dat ; add values in VGA0 to RAN.DAT open output 'junk' ; now assign OUTPUT to file JUNK type 'Area=' 3.14*R*R ; this goes to file JUNK type 'Area=' 3.14*R*R > terminal ; this is printed on the screen list 'ran.dat' > printer ; print file RAN.DAT on printer type vdata ; print VDATA values in file JUNK vecs ; print VECS values in file JUNK close output ; close the file assigned to OUTPUT When you close a file or channel using the CLOSE command, the associated channel returns to its default output device. However, when you redirect output using > or >>, after the command has finished the standard output channel, the function returns to whatever it was assigned to previously (see the last TYPE example above). If you use > or >> to redirect the output of a macro program, then all standard output produced by that macro will be redirected. Thus, mymacro > mac.dat is approximately equivalent to open output mac.dat mymacro close mac.dat See [[jvs:cigal:manual:chapter1:files|FILES(1)]] for more information on CIGAL's usage of disk files. **See Also:**\\ [[jvs:cigal|CIGAL Home]], [[jvs:cigal:manual|CIGAL Manual]], [[jvs:cigal:manual:chapter1|Topics List]], [[jvs:cigal:manual:help|Manual Help]]