in BASIC ROM:
|List of all BASIC keywords|
Type: Command General Programming-Syntax: CMD "<logical filenumber>"[,[string][;]]
The BASIC-command CMD changes the data output from the screen to another peripheral device like datasette, modem, printer or disk drive. CMD can be used directly or in programs. The logical filenumber can have values from 1 until 255 (reasonably <128) and must be selected with the BASIC-Command OPEN. When CMD is used without previous OPEN command, the BASIC-error "?FILE NOT OPEN ERROR" is reported. The logical filenumber used with CMD must be the same as in the previous OPEN command.
When the BASIC-Command CMD is executed, all PRINT- and LIST-commands are performed on the selected peripheral device. With the command PRINT#<logical filenumber> the data output can be returned to the screen before the device is closed with the BASIC-Command CLOSE<logical filenumber>.
When a BASIC-error occurs, the data output is returned to screen, too, butcharacters keep being sent to the logical file of the selected device. So the commands PRINT#1 and CLOSE must be executed for a correct abort of CMD.
OPEN 1,4,7: CMD 4, "Test on printer capital/small letters in program listing X": PRINT: LIST
(Redirecting of a BASIC program listing to a printer in capital/small letters) PRINT#1: CLOSE 1
(finishing redirecting of the data output)
10 REM Writing of a sequential file with 50 chars on datasette. 20 OPEN 1,1,1, "TESTFILE": CMD 1 30 FOR X=1 TO 50: PRINT X: NEXT X 40 PRINT#1: CLOSE 1
A demonstration of the crucial function of the semicolon in line number 110 and 140:
100 OPEN 3,3 110 CMD 3,"TEST"; 120 PRINT "TEXT" 130 PRINT "DEMO" 140 PRINT#3,; 150 CLOSE 3 160 PRINT "END";
This is the output on screen:
RUN TESTTEXT DEMOEND READY.