Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Migrating D7 on WinXP to Win10 - TSearchRec File(s) List

Status
Not open for further replies.

Patrick Allen

Programmer
Jan 25, 2019
7
US
I have some older source code ( ran on WinXP ) which I need to port to function on Win10. The basis for the code is to construct a list of filenames and list them in a listbox. The source is provided below … but, I need to replace it with similar code that works on the Win10 OS platform(s).

Can someone assist? … MANY THANKS IN ADVANCE

========= WinXP Era D7 Source Code ===================

procedure TfrmFormImport.InitializeFormsList;
var
SearchRec : TSearchRec;
szSearchStr : string;
szTmpStr1, szTmpStr2, szFormsPath : string;
begin
lboxForms.Clear;

szFormsPath := SQLFORMS + '*.sql';

szSearchStr := szFormsPath;

if FindFirst(szSearchStr, faAnyFile, SearchRec) = 0 then begin

szTmpStr1 := SearchRec.Name;

Delete(szTmpStr1, POS('.', szTmpStr1), 4);

szTmpStr2 := Copy(szTmpStr1, 1, Length(szTmpStr1));

if (not DataMod.tblOfflineForms.Locate('TableName', szTmpStr2, [])) then
lboxForms.Items.Add(szTmpStr2);

while FindNext(searchrec) = 0 do begin

szTmpStr1 := SearchRec.Name;

Delete(szTmpStr1, POS('.', szTmpStr1), 4);

szTmpStr2 := Copy(szTmpStr1, 1, Length(szTmpStr1));

if (not DataMod.tblOfflineForms.Locate('TableName', szTmpStr2, [])) then
lboxForms.Items.Add(szTmpStr2);

end;

FindClose(SearchRec);

end;

if lboxForms.Count = 0 then begin

memoSQLText.Clear;

InitializeDataAccessComponents;

end;
end;
 
What's the problem you're having with porting the code? Are you getting errors or incorrect behavior? What are you seeing and what are you expecting?

Mirtheil
 
Mirtheil …

The code is over a decade old and was compiled on a WinXP Pro OS. The code does the following:

1. Looks for files (in a specific folder) *.SQL
2. If it locates a *.SQL file, it places the file name string (minus the extension) into the list box for the user.

On a Win10 Pro box, the *.SQL files are in the folder, but are NOT being displayed in the listbox.

Patrick
 
And what debugging have you done? I ran the code you posted on a Windows 10 box using Delphi 5 (taking out references to DataMod since I don't have your whole code) and it worked correctly in that it showed me the list of SQL files in the directory I specified.

Mirtheil
 
mirtheil,

Thanks for jogging my memory. I rewrote the "suspected" procedure to remove the unnecessary coding ... as follows ... which led me to the offending procedure. Now the problem is solved. Once again, THANKS

procedure TfrmFormImport.InitializeFormsList;
var
SearchRec : TSearchRec;
szFormsPath : string;
begin
lboxForms.Clear;

szFormsPath := frmMain.szAppPath + SQLFORMS + '*.SQL'; { look for SQL files }

lblSearchPath.Caption := szFormsPath; { display the search path on the form }

if FindFirst(szFormsPath, faAnyFile, SearchRec) = 0 then begin

Delete(SearchRec.Name, POS('.', SearchRec.Name), 4);

if (not DataMod.tblOfflineForms.Locate('TableName', SearchRec.Name, [])) then
lboxForms.Items.Add(SearchRec.Name); { if the SQL file name is not in the database, then add to list }

while FindNext(searchrec) = 0 do begin

Delete(SearchRec.Name, POS('.', SearchRec.Name), 4);

if (not DataMod.tblOfflineForms.Locate('TableName', SearchRec.Name, [])) then
lboxForms.Items.Add(SearchRec.Name);

end;

FindClose(SearchRec);

end;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top