CnPack Forum » CnWizards IDE Wizards » What' mistake in code?


2012-7-1 20:11 greenpower
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

2012-7-2 10:59 Passion
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?

2012-7-2 12:01 greenpower
[img]http://projectmp3.3dn.ru/phizics/bezymjannyj.jpg[/img]

2012-7-2 17:25 Passion
Maybe you need to add "Path: string;" declaration in var section?

2012-7-3 03:30 greenpower
thanks, good service

页: [1]
查看完整版本: What' mistake in code?


Powered by Discuz! Archiver 5.0.0  © 2001-2006 Comsenz Inc.