I have managed to make it work with the following, rather then using 2 listbox
but im not sure if this is a viable method, is it possible some with uber skill
check to see if its ok to use like this. I can say it works as needed and compiles
without any errors. But will it cause problems later ???
For whatever reason after the first loop it should exit the procedure then call it again
in order to parse the next deliimited string. i I used the clickevent for each instance
what im worried about is iNum is never initialized, usally I would put
iNum :=0; in form activate procedure. but if I do that then Code will not
ever reach the next delimited line and add to the the listbox.
var
Form1: TForm1;
Contacts: TStringList;
iNum: Integer;
iCount: Integer;
procedure TForm1.Button1Click(Sender: TObject);
begin
Contacts := TStringList.Create;
Contacts.LoadFromFile('/home/technet/blah1.txt');
// blah1.txt contains 2 lines below
William:Jackson:2342342432:34242342423:34234 n B:Abilene:TX:34234
Elaine:Moor:5345345351:98724239872:42342 jb hunt:Lonestar:OK:35344
Contacts.Delimiter := ':';
Contacts.StrictDelimiter := TRUE;
iCount := Contacts.Count;
for iNum := iNum to iCount - 1 do
begin
//showmessage(IntToStr(iNum)); // Testing purpose only
try
Contacts.DelimitedText:= Contacts.Strings[iNum];
lstContacts.Items.Add(Contacts.ValueFromIndex[0] + ' ' + Contacts.ValueFromIndex[1]);
except;
//application.ProcessMessages; // Testing purpose only
//sleep(3000); // Testing purpose only
contacts.Free;
button1click(sender)
end;
end;
end;