Subject:
What' mistake in code?
[Print This Page]
Author:
greenpower
Time:
2012-7-1 20:11
Subject:
What' mistake in code?
var
SearchRec: TSearchRec;
SearchResults: Integer;
ImagesList: TStringList;
MyRnd : Integer;
begin
ImagesList:= TStringList.Create;
try
Path:= '?:\MySuperDir\MySuperSubDir\';
SearchResults := FindFirst(Patch + '*.bmp', faAnyFile, SearchRec);
while SearchResults = 0 do
begin
if SearchRec.Attr <> faDirectory then ImagesList.Add(Patch + SearchRec.Name);
SearchResults := FindNext(SearchRec);
end;
FindClose(SearchRec);
if ImagesList.Count > 0 then
begin
Randomize;
MyRnd := Random(ImagesList.Count);
Image1.Picture.LoadFromFile(ImagesList[MyRnd]);
end;
finally
FreeAndNil(ImagesList);
end;
end;
Help me, please
Author:
Passion
Time:
2012-7-2 10:59
What's the error message in compile time or runtime?
And, the 'Path' constant includes a '?', maybe it's an illegal character in your program?
Author:
greenpower
Time:
2012-7-2 12:01
Author:
Passion
Time:
2012-7-2 17:25
Maybe you need to add "Path: string;" declaration in var section?
Author:
greenpower
Time:
2012-7-3 03:30
thanks, good service
Welcome to CnPack Forum (http://bbs.cnpack.org/)
Powered by Discuz! 5.0.0