Page 1 of 1

PicShow not Random

PostPosted: November 7th, 2007, 6:54 pm
by Tabakbrummel
Hi
I come from Germany because the bad English.
My problem is that I PicShow not with the Random wants.



Code: Select all
// Selects randomly an image from the list and loads it in to PicShow
procedure TMainForm.LoadNextImage;
var
  Index: Integer;
begin
  LoadedImage := '';
  if Pictures.Count > 0 then
  begin
    repeat
      Index := Random(Pictures.Count);//What must I change there ???
    until (Pictures.Count <= 1) or (ShowingImage <> Pictures[Index]);
    LoadedImage := Pictures[Index];
    PicShow.Picture.LoadFromFile(PicturesPath + '\' + LoadedImage);
  end;
end;


Thank you
Uwe

PostPosted: November 7th, 2007, 9:04 pm
by Kambiz
I guess you need the following code:

Code: Select all
var
  LoadedIndex: Integer = -1;

procedure TMainForm.LoadNextImage;
begin
  if Pictures.Count > 0 then
  begin
    Inc(LoadedIndex);
    if LoadedIndex >= Pictures.Count then
      LoadedIndex := 0;
    LoadedImage := Pictures[LoadedIndex];
    PicShow.Picture.LoadFromFile(PicturesPath + '\' + LoadedImage);
  end;
end;

PostPosted: November 7th, 2007, 9:14 pm
by Tabakbrummel
Hi Kambiz

First, many thanks to a lot of work and greetings from Germany.

Thank you
Uwe

PostPosted: November 8th, 2007, 10:50 pm
by Kambiz
You're welcome!