CnPack Forum


 
Subject: What' mistake in code?
greenpower
新警察
Rank: 1



UID 67603
Digest Posts 0
Credits 8
Posts 3
点点分 8
Reading Access 10
Registered 2012-7-1
Status Offline
Post at 2012-7-1 20:11  Profile | Blog | P.M. 
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
Top
Passion (LiuXiao)
管理员
Rank: 9Rank: 9Rank: 9


UID 359
Digest Posts 19
Credits 6750
Posts 3551
点点分 6750
Reading Access 102
Registered 2004-3-28
Status Offline
Post at 2012-7-2 10:59  Profile | Blog | P.M. 
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?
Top
greenpower
新警察
Rank: 1



UID 67603
Digest Posts 0
Credits 8
Posts 3
点点分 8
Reading Access 10
Registered 2012-7-1
Status Offline
Post at 2012-7-2 12:01  Profile | Blog | P.M. 
Top
Passion (LiuXiao)
管理员
Rank: 9Rank: 9Rank: 9


UID 359
Digest Posts 19
Credits 6750
Posts 3551
点点分 6750
Reading Access 102
Registered 2004-3-28
Status Offline
Post at 2012-7-2 17:25  Profile | Blog | P.M. 
Maybe you need to add "Path: string;" declaration in var section?
Top
greenpower
新警察
Rank: 1



UID 67603
Digest Posts 0
Credits 8
Posts 3
点点分 8
Reading Access 10
Registered 2012-7-1
Status Offline
Post at 2012-7-3 03:30  Profile | Blog | P.M. 
thanks, good service
Top
 




All times are GMT++8, the time now is 2024-3-29 03:38

    本论坛支付平台由支付宝提供
携手打造安全诚信的交易社区 Powered by Discuz! 5.0.0  © 2001-2006 Comsenz Inc.
Processed in 0.007262 second(s), 9 queries , Gzip enabled

Clear Cookies - Contact Us - CnPack Website - Archiver - WAP