'make a quick file for testing purposes
PRINT "Creating data file. Please wait a moment....." PRINT #1, "This is line #"; i;
". And here's my number: ";
INT(RND * 10000000) PRINT "Data file created. Now doing time tests...."
'Start the timer
FileToArray "temp.txt", lines()
PRINT USING "Loaded and parsed #,###,### lines, in ###.#### seconds."; count
, t1##
- t##
'and here's an example using an array which starts at index 1, instead of 0
FileToArray "temp.txt", lines()
PRINT USING "Loaded and parsed #,###,### lines, in ###.#### seconds."; count
, t1##
- t##
PRINT "And to compare times..." count = 1000000
REDIM lines
(1000000) AS STRING 'I'm going to cheat here and correctly size the lines array from the start ' to shave off a little time constantly resizing it, and to keep my test code down to just
' the time it takes for the program to load.
PRINT USING "Using FOR INPUT, I loaded and parsed #,###,### lines, in ###.#### seconds."; count
, t1##
- t##
REDIM lines
(1000000) AS STRING 'I'm going to cheat here and correctly size the lines array from the start 'to shave off a little time constantly resizing it, and to keep my test code down to just
'the time it takes for the program to load.
PRINT USING "Using FOR BINARY, I loaded and parsed #,###,### lines, in ###.#### seconds."; count
, t1##
- t##
FileToArray "temp.txt", lines()
PRINT USING "Using FileToArray, I loaded and parsed #,###,### lines, in ###.#### seconds."; count
, t1##
- t##
GET #FileToArray_Handle
, 1, temp$
CLOSE #FileToArray_Handle
'find CRLF
'if there's no line endings, then simply just send what we have as a single line.
count
= LBOUND(FileToArray_lines
) IF FileToArray_CRLF
= "" THEN REDIM FileToArray_lines
(count
TO count
): FileToArray_lines
(count
) = temp$:
EXIT SUB 'parse into an array
U = 1000000 + count
L
= INSTR(l1
, temp$
, FileToArray_CRLF
) FileToArray_lines
(count
) = MID$(temp$
, l1
, L
- l1
) l1
= L
+ LEN(FileToArray_CRLF
) count = count + 1
FileToArray_lines
(count
) = MID$(temp$
, l1
)