Author: Jonas Bilinkevicius
I should give an example of what I'm trying to do. The NewTrackList procedure is
supposed to create a list of 14 numbers from 1 to 14, with no numbers repeated. The
list is supposed to be random, that is, a different sequence of numbers is created
every time the procedure runs.
Answer:
1 2 procedure NewTrackList;
3 var4 TrackNumbersList: array[1..14] of Integer;
5 I, II: Integer;
6 SameTracks: Boolean;
7 S: string;
8 begin9 for I := 1 to 14 do10 TrackNumbersList[I] := 0;
11 for I := 1 to 14 do12 begin13 TrackNumbersList[I] := Random(14) + 1;
14 repeat15 SameTracks := False;
16 for II := 1 to I - 1 do17 begin18 if I = 1 then19 Break;
20 if TrackNumbersList[I] = TrackNumbersList[II] then21 begin22 SameTracks := True;
23 TrackNumbersList[I] := Random(14) + 1;
24 Break;
25 end;
26 end;
27 until28 not SameTracks;
29 end;
30 S := '';
31 for I := 1 to 14 do32 S := S + ' ' + IntToStr(TrackNumbersList[I]);
33 Form1.Label1.Caption := S;
34 end;
35 36 procedure TTunesMain.FormCreate(Sender: TObject);
37 begin38 Randomize;
39 NewTrackList;
40 end;
S is a local variable of type String. I obviously added a TLabel to the form, as well.