Wednesday, March 27, 2019

If you must to create quick and dirty quasi database system



SAVE / LOAD procedure:

procedure TForm1.Button1Click(Sender: TObject);
var strl : TStringlist;
begin
//SAVE
strl := TStringList.Create;
strl.Add(Edit1.Text);
strl.Add(Edit2Text);

strl.Add(Edit3.Text);

strl.Add(Edit4.Text);

//etc...
strl.SaveToFile('C:\test.txt');
strl.Free;
//LOAD
strl := TStringList.Create;
strl.LoadFromFile('C:\test.txt');
Edit1.Text := strl.strings[0];
Edit2.Text := strl.strings[1];
Edit3.Text := strl.strings[2];
Edit4.Text := strl.strings[3];
//etc...
strl.Free;
end;

//You can use this procedure for C:\test1.txt...C:\test[FileMaxCount].txt
//Same procedure, but different text file name.
//All data will be saved as strings in sequential order.
//One textual file presents one row of data, if you have 1000 rows of data, than you have 1000 textual files.
//That system is very fast, faster than any CSV file with all data.
//You don't need to search for data loading all data, but only data that contents particular textual file.
//That system save resources and memory.
//It is not very well solution, but is quick and dirty one.
//Another "benefit" of that system is the lack of any delimiters in that files, except CRLF.



No comments:

Post a Comment

Коментар: