Load TextFiles To String Array

Started by kevin, May 28, 2007, 07:59:44 AM

Previous topic - Next topic

kevin

   This example looks the fastest way to load a text file into a string array in PlayBasic V1.62 and bellow.  It includes two versions of the Loader function. The first  reads the data to memory then  manually grabs cuts and pastes this into the individual strings,  the second read strings and throws them into the array directly.     While the latter is less code, it's also dramatically slower! Around 50 times slower in fact.     So if you need to load a text file into a string array, i'd recommend using the first version !

    Load String to array

kevin

#1
    This example looks at the fastest ways of loading large text files into a string array in PlayBasic V1.64 or bellow.

   This version of the test includes 4 methods.  Where the previous test only had two.  Those being a spooling approach and parsing approach  through a memory bank.   Both examples are still included, but i've added another pair.  The first is based upon PB's SplitToArray() function, and the latter is a variation of the memory bank code, except this one uses PB string functions to cut the textfile into lines.
 
   Speed wise the two new loaders at the fastest,  both being about 5->6  times faster than the memory bank version.  And between 1500->3000 times  faster then simple spooling routine..  

   So if you need to load a text file into a string array quickly, then  i'd recommend using the first version, if you want more accuracy then the String version !

Related To

    Load File To String & Save String As File
   A Crash Course In Optimization



Download Attached