Forum > Database
BufDataSet - LoadFromFile problem
howardpc:
For persistent data saved to a textfile you can organise your file so that the first line saved with SaveToText represents the field structure (fieldname, type, and length). Your LoadTextFile procedure would then parse the first line read as a special composite value whose individual parts enable you to reconstruct the correct TFieldDefs for your BufDataSet. Or you can save this information as a separate schema file which LoadTextFile opens and reads first.
Either way, once the correct database structure is determined, LoadTextFile can continue to read individual records using ReadLn, parsing each record into its constituent fields which are appended to the dataset in memory.
Note that best practice is to use TextFile (rather than Text) as the file type. If you ever migrate your code to a GUI app, use of Text will most likely produce unwelcome name clashes with the Text properties of numerous classes.
Navigation
[0] Message Index
[*] Previous page