WRITE (file statement) - mkilgore/QB64pe GitHub Wiki
The WRITE # file statement writes a list of comma separated variable values to a sequential file or port.
- WRITE (file statement)filenumber&[,]
- filenumber& is the number of the file or device OPENed in the OUTPUT or APPEND modes. See: FREEFILE.
- expressionList is a comma-separated list of values to be written to the file or device.
- WRITE can place any number and types of variable values needed in a file record separated by commas.
- String values will have quotation marks although quotes are not required to read strings in CSV files with INPUT #.
- Data files using WRITE normally will have the same number of values listed on each file line.
- Data containing commas must be in quotation marks. Number commas are illegal!
- WRITE created files are normally read with INPUT #.
- CSV files created can be read by Excel using a .CSV file name extension. Strings may or may not include quotation marks.
- Semicolons cannot be used in or following the WRITE statement!
OPEN filename$ FOR...NEXT OUTPUT AS #1 'opens and clears an existing file or creates new empty file WRITE (file statement) #1, x, y, z$ CLOSE #1 PRINT "File created with data. Press a key!" K$ = INPUT$(1) 'press a key OPEN filename$ FOR (file statement) INPUT (file mode) AS #2 'opens a file to read it INPUT (file statement) #2, a, b, c$ CLOSE #2 PRINT a, b, c$ WRITE a, b, c$ END '' '' |
- File content: WRITE string values will include quotation marks, but they are not required to read the file.
1,2,"Three" |
1 2 Three 1,2,"Three" |
- PRINT #
- INPUT #
- LINE INPUT #
- SQL Client (library)
Navigation:
Go to Keyword Reference - Alphabetical
Go to Keyword Reference - By usage
Go to Main WIKI Page