4MELFA-BASIC IV
Detailed explanation of command words
4-238
Print (Print)
[Function]
Outputs data into a file
(including communication lines)
. All data uses the AscII format.
[Format]
[Terminology]
<File No.>
Described with numbers 1 to 8.
Corresponds to the control No. assigned by the Open command.
<Expression>
Describes numeric operation expressions, position operation expressions and character
string expressions.
[Reference Program]
1 Open "COM1" AS #1
' Open standard RS-232-C line as file No. 1.20 Mov P_01.
2 MDATA=150
' Substitute 150 for the numeric variable MDATA.
3 Print #1,"***Print TEST***"
' Outputs the character string "***Print TEST****."
4 Print #1
' Issue a carriage return
5 Print #1,"MDATA=",MDATA
' Output the character string "MDATA" followed by the value of
MDATA, (150).
6 Print #1
' Issue a carriage return.
4 Print #1,"****************"
' Outputs the character string "**************."
5 End
' End the program.
The output result is shown below.
***Print TEST***
MDATA=150
****************
[Explanation]
(1) If <Expression> is not described, then a carriage return will be output.
(2) Output format of data (reference)
The output space for the value for <Expression> and for the character string is in units of 14 characters.
When outputting multiple values, use a comma between each <Expression> as a delimiter.
If a semicolon (;) is used at the head of each space unit, it will output after the item that was last dis-
played. The carriage return code will always be returned after the output data.
(3) The error occurs when Open command is not executed.
(4) If data contains a double quotation mark ("), only up to the double quotation mark is output.
Example)
[1 M1=123.5
2 P1=(130.5,-117.2,55.1,16.2,0.0,0.0)(1,0) ]
1)[3 Print #1,"OUTPUT TEST",M1,P1]is described,
OUTPUT TEST 123.5 (130.5,-117.2,55.1,16.2,0.0,0.0)(1,0) is output.
2)[3 Print #1,"OUTPUT TEST";M1;P1]is described,
OUTPUT TEST 123.5(130.5,-117.2,55.1,16.2,0.0,0.0)(1,0) is output.
If a comma or semicolon is inserted after a <Expression>, the carriage return will not be issued, and instead,
printing will continue on the same line.
3) 3 Print #1,"OUTPUT TEST",
4 Print #1,M1;
5 Print #1,P1 ]is described,
OUTPUT TEST 123.5(130.5,-117.2,55.1,16.2,0.0,0.0)(1,0) is output.
[Related instructions]
Print[]#<File No.>[] [, [<Expression> ; ] ...[<Expression>[ ; ]]]