Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
var
TempStringList : TStringList;
ALineStrList : TStringList;
ANewTable : TTable;
i, j : Integer;
begin
if OpenDialog.Execute then
begin
TempStringList := TStringList.Create;
ALineStrList := TStringList.Create;
ANewTable := TTable.Create(Self);
try
TempStringList.LoadFromFile(OpenDialog.FileName);
if (TempStringList.Count = 0)then
Exit;
ALineStrList.Text := StringReplaceTempStringList.Strings[0], ' ', #10, [rfReplaceAll]);
// Creating fields
with ANewTable do
begin
StoreDefs := False;
TableType := ttParadox;
TableName := 'C:\MyNewTable.db';
with FieldDefs do
begin
for i := 0 to ALineStrList.Count - 1 do
begin
with AddFieldDef do
begin
Name := Format('Field_%d', [i + 1]);
DataType := ftString;
Size := 50;
end;
end;
end;
CreateTable();
// Filling table with data.
Active := True;
for i := 0 to TempStringList.Count - 1 do
begin
ALineStrList.Text := StringReplaceTempStringList.Strings[0], ' ', #10, [rfReplaceAll]);
Insert;
for j := 0 to Fields.Count - 1 do
begin
FieldByName(Format('Field_%d', [j + ])).asString := ALineStrList.Strings[i];
end;
Post;
end;
Active := False;
end;
finally
ANewTable.Free;
ALineStrList.Free;
TempStringList.Free;
end;
end;
end;
[\code]
But here made a lot of assumptions like i assume that you need to store data as string only, and that every row contains all fields' values. If i had more time i would add code for determening maximal length of a value e.t.c. But this Eric's example and this can be something you may start with.
Hope that helps.
--- markus