Microsoft KB Archive/61962

The Difference Between Write and Print in WordBASIC

PSS ID Number: Q61962 Article last modified on 06- 6-1991

1.00 MS-DOS

Summary: Microsoft WordBASIC’s Print and Write commands are similar – both can be used to write text to a file. However, there are some differences in how information is stored that should be taken into consideration before one or the other is used. For the explanations below, assume the following: A$ = “Test Text” B$ = “Sample” A = 21 B = 93.0427 #1 has been defined as a stream number with Open The Print command writes information to a file exactly as it appears. For example, the command Print #1, A$ would send the text Test Text (and a carriage return) to the file indicated by #1. If two or more variables are included on the command line, then each variable is printed to the file, separated by a TAB (CTRL+I) character. The command Print #1, A$, B$, A, B would send the text Test Text Sample 21 93.0427 (and a carriage return) to #1, related to a text file generated by Microsoft Excel. Write, on the other hand, places quotation marks around all text values (but not numeric data) and separates two or more values on the same command line with commas. The line Write #1, A$ would send the text “Test Text” (and a carriage return), including the quotation marks, to #1, and Write #1, A$, B$, A, B would send the text “Test Text”, “Sample”, 21, 93.0427 (and a carriage return) to #1, related to a CSV (comma separated values) file generated by Microsoft Excel.

Additional reference words: w4wmacro