Загружаются строки из текстового файла. Нужно рандомно добавить в лейбл 1,4,7,10.....34,37 (1+3).. (пока делаю хотя бы с 3 строками 1,4,7)
код
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Math;
type
TForm1 = class(TForm)
Label1: TLabel;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
var f1:TextFile;
i,n,j,k:integer;
chislo:String;
vop:array[1..9] of String;
a:array[1..9] of integer;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
n:=1;
randomize;
assignfile(f1,'Test.txt');
reset(f1);
for i:=1 to 9 do begin
readln(f1,chislo);
vop[i]:=chislo;
for j:=1 to 3 do begin
a[j]:=a[j]+n;
n:=n+3;
begin
k:=RandomRange(1, 3);
Label1.Caption:=vop[a[k]];
end;
CloseFile(F1);
end;
end;
end;
Помогите разобраться где проблема. при запуске высвечивается окошко с еррором но программа все равно через раз запускается и выдает один и тот же ответ.