reading_20and_20writing_20plain_20text_20files
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
reading_20and_20writing_20plain_20text_20files [2018/03/31 13:19] – external edit 127.0.0.1 | reading_20and_20writing_20plain_20text_20files [2024/01/05 00:21] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 2: | Line 2: | ||
//by Richard Russell, August 2007//\\ \\ Standard text files, such as are created by text editors like Windows **Notepad** or MS-DOS **EDIT**, consist of lines of plain text separated by the character sequence //Carriage Return, Line Feed// (usually abbreviated as **CRLF**). Plain text files are probably the most universal of all file formats, especially if you limit their contents to the 7-bit [[http:// | //by Richard Russell, August 2007//\\ \\ Standard text files, such as are created by text editors like Windows **Notepad** or MS-DOS **EDIT**, consist of lines of plain text separated by the character sequence //Carriage Return, Line Feed// (usually abbreviated as **CRLF**). Plain text files are probably the most universal of all file formats, especially if you limit their contents to the 7-bit [[http:// | ||
+ | <code bb4w> | ||
LF = 10 | LF = 10 | ||
Line 16: | Line 17: | ||
CLOSE #outfile% | CLOSE #outfile% | ||
+ | </ | ||
Note that numeric values must be written as strings, hence the [[http:// | Note that numeric values must be written as strings, hence the [[http:// | ||
+ | <code bb4w> | ||
LF = 10 | LF = 10 | ||
Line 32: | Line 35: | ||
CLOSE #infile% | CLOSE #infile% | ||
+ | </ | ||
Since the **LF** //follows// the terminating **CR** it will appear as the //first// character in each record (except the first record). Note that numeric values must be read as a string and converted back to a number, hence the [[http:// | Since the **LF** //follows// the terminating **CR** it will appear as the //first// character in each record (except the first record). Note that numeric values must be read as a string and converted back to a number, hence the [[http:// | ||
+ | <code bb4w> | ||
DEF FNreadline(F%) | DEF FNreadline(F%) | ||
LOCAL A$ | LOCAL A$ | ||
Line 38: | Line 43: | ||
IF A$="" | IF A$="" | ||
= A$ | = A$ | ||
+ | </ | ||
This function will correctly return blank lines, when they are present in the file. If you're not interested in blank lines, and want to discard them, you can use this function instead: | This function will correctly return blank lines, when they are present in the file. If you're not interested in blank lines, and want to discard them, you can use this function instead: | ||
+ | <code bb4w> | ||
DEF FNreadlinenoblank(F%) | DEF FNreadlinenoblank(F%) | ||
LOCAL A$ | LOCAL A$ | ||
Line 45: | Line 52: | ||
UNTIL A$<>"" | UNTIL A$<>"" | ||
= A$ | = A$ | ||
+ | </ |
reading_20and_20writing_20plain_20text_20files.1522502376.txt.gz · Last modified: 2024/01/05 00:16 (external edit)