With all the tips and help I've found I've developed the following procedure. It allows the user to select the file to upload and then should look at each line and extract the needed information. When I run the code, the Open File Dialog box opens, I select my file, but when it gets to the "While Not EOF Do" I get an I/O error. When I use the debugger, I find that my file is still NOTHING!
procedure TfrmMainMenu.UploadVenire1Click(Sender: TObject);
var
F: TextFile;
S: string;
FullName, LastName, FirstName, Address, City, State, Zip, TermDate: string;
begin
if OpenDialog1.Execute then { Display Open dialog box }
begin
AssignFile(F, OpenDialog1.FileName); { File selected in dialog }
Reset(F);
While Not EOF do
begin
Readln(F, S); { Read first line of file }
FullName := Copy(S, 160,30); // extract name
Address := copy(S,190,25); // extract address
City := copy(S, 215,15); //extract city
State := copy(S, 230, 2);
Zip := copy(S, 232,9);
TermDate := copy(S, 16,6);
end;
CloseFile(F);
end;
end;
Thanks for any input!
Leslie
procedure TfrmMainMenu.UploadVenire1Click(Sender: TObject);
var
F: TextFile;
S: string;
FullName, LastName, FirstName, Address, City, State, Zip, TermDate: string;
begin
if OpenDialog1.Execute then { Display Open dialog box }
begin
AssignFile(F, OpenDialog1.FileName); { File selected in dialog }
Reset(F);
While Not EOF do
begin
Readln(F, S); { Read first line of file }
FullName := Copy(S, 160,30); // extract name
Address := copy(S,190,25); // extract address
City := copy(S, 215,15); //extract city
State := copy(S, 230, 2);
Zip := copy(S, 232,9);
TermDate := copy(S, 16,6);
end;
CloseFile(F);
end;
end;
Thanks for any input!
Leslie