program testcsv;
{$MODE OBJFPC}{$H+}
Uses
StrUtils;
procedure SimClick;
var
TxtFile : TextFile;
SVal,Ch : String;
FName : String;
wCnt : Integer; // number of textual words
wIndex : Integer; // index to textual words
begin
FName := 'test.csv';
AssignFile(TxtFile, FName);
Reset(TxtFile);
ReadLn(TxtFile, Ch);
// You are required to close the file when you are done reading from it
CloseFile(TxtFile);
// Retrieve number of textual words (separated by given delimiters) from string
wCnt := WordCount(Ch, [',' , ';' , #9]);
// For every textual word
for wIndex := 1 to WCnt do
begin
// 'extract' the current textual word with index wIndex from string Ch
SVal := ExtractWord(wIndex, Ch, [',' , ';' , #9]);
// Depending on which word(index) was 'extracted', add the actual text of the filedname to the corresponding Combobox
Case wIndex of
1 : WriteLn('Add field 1 with name "', SVal, '" to combobox1'); // ComboBox1.Items.Add(SVal);
2 : WriteLn('Add field 2 with name "', SVal, '" to combobox2'); // ComboBox2.Items.Add(SVal);
3 : WriteLn('Add field 3 with name "', SVal, '" to combobox3'); // ComboBox3.Items.Add(SVal);
end;
end;
end;
begin
SimClick;
end.