Syntax |
Print #filenumber, [[{Spc(n) | Tab(n)}][expressionlist][{;|,}]] |
|
Description |
Writes data to a sequential disk file. |
|
Comments |
The filenumber parameter is a number that is used by the Basic Control Engine to refer to the open file, the number passed to the Open statement. The following table describes how data of different types is written: |
|
|
Data Type |
Description |
|
String |
Printed in its literal form, with no enclosing quotes. |
|
Any numeric type |
Printed with an initial space reserved for the sign (space = positive). Additionally, there is a space following each number. |
|
Boolean |
Printed as TRUE or FALSE. |
|
Date |
Printed using the short date format. If either the date or time component is missing, only the provided portion is printed (this is consistent with the "general date" format understood by the Format/Format$ functions). |
|
Empty |
Nothing is printed. |
|
Null |
Prints NULL. |
|
User-defined errors |
Printed to files as "Error code", where code is the value of the user-defined error. The word "Error" is not translated. |
|
Each expression in expressionlist is separated with either a comma (,) or a semicolon (;). A comma means that the next expression is output in the next print zone. A semicolon means that the next expression is output immediately after the current expression. Print zones are defined every 14 spaces. If the last expression in the list is not followed by a comma or a semicolon, then an end-of-line is printed to the file. If the last expression ends with a semicolon, no end-of-line is printed¾the next Print statement will output information immediately following the expression. If the last expression in the list ends with a comma, the file pointer is positioned at the start of the next print zone on the current line. |
|
|
The Write statement always outputs information ending with an end-of-line. Thus, if a Print statement is followed by a Write statement, the file pointer is positioned on a new line. The Print statement can only be used with files that are opened in Output or Append mode. The Tab and Spc functions provide additional control over the file position. The Tab function moves the file position to the specified column, whereas the Spc function outputs the specified number of spaces. In order to correctly read the data using the Input# statement, you should write the data using the Write statement. |
|
Example |
Sub Main() 'This example prints the value of
i% in print zone 1 and s$ in 'This example prints the value of
i% and s$ separated by ten spaces. 'This example prints the value of i
in column 1 and s$ in column 30. 'This example prints the value of
i% and s$. |
|
See Also |
||
Note |
The end-of-line character can be either the carriage-return/line-feed pair, or the line-feed character. |
If you want it to go to a file you need the # otherwise it goes to standard out and uses the first variable (in thise case f) as the first item to output to standard out. So that print line should be
Print #F, "This is a test"
P |