To write a single line, you can use a PRINT# statement. A $CRLF will be appended automatically when the items to be printed have been written to file. If you add a semi-colon at the end of the PRINT# statement, this will suppress the generation of the $CRLF. Thus, more than one PRINT# statement can put items on the same line in the file. If you use a comma (,) instead, you will insert a type of tab operator at that point. This could actually cause a tab to occur, or force a tab character (CHR$(9)) to appear at that point, or just insert a comma. Which occurs depends on the device being written to, and the implementation of that function in the language being used.
If you use this statement, PRINT#1, a b, and a is equal to 26, with b equal to 59, what will appear in your file will be this:
Code:
26 59
If you instead use this statement PRINT#1 a,b then your file content will probably look like this:
Code:
26 59
Code:
26, 59
And the best way to ensure that you end up with a tab character separating a and b is to do it this way: PRINT#1, a $TAB b or PRINT#1, a CHR$(9) b
This is beneficial if you are writing CSV compatible sequential files.
If you want to write sequential files that are compatible with other OSes, you may need to do it this way: PRINT#1,a b $LF;
While it is possible to use the WRITE command instead of the PRINT command, I've never found it necessary to do so.
Leave a comment: