First Question: how do i get a random number from an array. i have made an array from 1..45, and declared what each one is, it has 1..9 are 1, 1..17 are 2 and so on. and i want to get a random one of these from the array.
Second Question: How do i make an if that does someting like this:
IF check = check1 then
begin
(then i make things multiply).
end;
(i would be doing this for checker = check and check1, check = checker

and checker = check1.
Third Question: how would i make a hold function(i am making a fruit machine)that has a 5050 chance to get to hold, and you can hold upto 2 columns(out of 3).
to help in answering i have posted my entire program below.
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
program fruitmachine;

uses crt;

var bet,semibank,spin,bank,winings,yahoo,endscreen,endscreenwin,mulitplier,holdyn,checker,check,check1,written,blob,hold5050,rand:integer;
var fruit : array[1..9] of string;
var rare : array[1..45] of integer;

begin
repeat
//random table
rare[1]:=1;
rare[2]:=1;
rare[3]:=1;
rare[4]:=1;
rare[5]:=1;
rare[6]:=1;
rare[7]:=1;
rare[8]:=1;
rare[9]:=1;
rare[10]:=2;
rare[11]:=2;
rare[12]:=2;
rare[13]:=2;
rare[14]:=2;
rare[15]:=2;
rare[16]:=2;
rare[17]:=2;
rare[18]:=3;
rare[19]:=3;
rare[20]:=3;
rare[21]:=3;
rare[22]:=3;
rare[23]:=3;
rare[24]:=3;
rare[25]:=4;
rare[26]:=4;
rare[27]:=4;
rare[28]:=4;
rare[29]:=4;
rare[30]:=4;
rare[31]:=5;
rare[32]:=5;
rare[33]:=5;
rare[34]:=5;
rare[35]:=5;
rare[36]:=6;
rare[37]:=6;
rare[38]:=6;
rare[39]:=6;
rare[40]:=7;
rare[41]:=7;
rare[42]:=7;
rare[43]:=8;
rare[44]:=8;
rare[45]:=9;
cursoroff;
//Initialising fruits
fruit[1]:=' cherry ';
fruit[2]:=' banana ';
fruit[3]:=' lemon ';
fruit[4]:=' orange ';
fruit[5]:=' bar ';
fruit[6]:=' melon ';
fruit[7]:=' coconut ';
fruit[8]:=' bell ';
fruit[9]:=' butter ';

//writing of reels:
gotoxy(25,10);
write(char(201));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(203));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(203));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(187));

gotoxy(25,11);
write(char(186));
gotoxy(36,11);
write(char(186));
gotoxy(47,11);
write(char(186));
gotoxy(58,11);
write(char(186));

gotoxy(25,12);
write(char(186));
gotoxy(36,12);
write(char(186));
gotoxy(47,12);
write(char(186));
gotoxy(58,12);
write(char(186));

gotoxy(25,13);
write(char(186));
gotoxy(36,13);
write(char(186));
gotoxy(47,13);
write(char(186));
gotoxy(58,13);
write(char(186));

gotoxy(25,14);
write(char(186));
gotoxy(36,14);
write(char(186));
gotoxy(47,14);
write(char(186));
gotoxy(58,14);
write(char(186));

gotoxy(25,15);
write(char(186));
gotoxy(36,15);
write(char(186));
gotoxy(47,15);
write(char(186));
gotoxy(58,15);
write(char(186));

gotoxy(25,16);
write(char(186));
gotoxy(36,16);
write(char(186));
gotoxy(47,16);
write(char(186));
gotoxy(58,16);
write(char(186));

gotoxy(25,17);
write(char(186));
gotoxy(36,17);
write(char(186));
gotoxy(47,17);
write(char(186));
gotoxy(58,17);
write(char(186));

gotoxy(25,18);
write(char(186));
gotoxy(36,18);
write(char(186));
gotoxy(47,18);
write(char(186));
gotoxy(58,18);
write(char(186));

gotoxy(25,19);
write(char(186));
gotoxy(36,19);
write(char(186));
gotoxy(47,19);
write(char(186));
gotoxy(58,19);
write(char(186));

gotoxy(25,20);
write(char(200));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(202));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(202));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(205));
write(char(188));
//end of writing blank reels
//instructions:
gotoxy(60,10);
write('INSTRUCTIONS:');
gotoxy(60,11);
write('-type 4 to quit');
gotoxy(60,12);
write('-type 01 to to bank');
gotoxy(60,13);
gotoxy(60,14);
write('to hold...');
gotoxy(60,15);
write('YOU MUST BET OVER 5!');

repeat
gotoxy(30,4);
write('place a bet');
cursoron;
gotoxy(30,5);
write(' ');
gotoxy(30,5);

cursoroff;
//to BANK:
if bet = 01 then
begin
winings:=semibank;
end;
until (bet > 5) or (bet = 4);
//resetting the spin:
spin:=0;

//if bet is 4 it skips to end scene(0 is the quit function)
//at first i tried to do it with an IF statement, but it disabled
//the ability to play the game. i then, whilst writing these notes, the
//repeat-until did the job just fine.
//'spinning' animation:
if bet > 5 then
begin
repeat

//randomizer
//left reel
randomize;
rand:=random(8);
rand:=rand+1;
gotoxy(26,15);
if rand = 1 then
begin
checker:=1;
write(fruit[1]);
end;
if rand = 2 then
begin
checker:=2;
write(fruit[2]);
end;
if rand = 3 then
begin
checker:=3;
write(fruit[3]);
end;
if rand = 4 then
begin
checker:=4;
write(fruit[4]);
end;
if rand = 5 then
begin
checker:=5;
write(fruit[5]);
end;
if rand = 6 then
begin
checker:=6;
write(fruit[6]);
end;
if rand = 7 then
begin
checker:=7;
write(fruit[7]);
end;
if rand = 8 then
begin
checker:=8;
write(fruit[8]);
end;
if rand = 9 then
begin
checker:=9;
write(fruit[9]);
end;
//center reel
rand:=random(8);
rand:=rand+1;
gotoxy(37,15);
if rand = 1 then
begin
check:=1;
write(fruit[1]);
end;
if rand = 2 then
begin
check:=2;
write(fruit[2]);
end;
if rand = 3 then
begin
check:=3;
write(fruit[3]);
end;
if rand = 4 then
begin
check:=4;
write(fruit[4]);
end;
if rand = 5 then
begin
check:=5;
write(fruit[5]);
end;
if rand = 6 then
begin
check:=6;
write(fruit[6]);
end;
if rand = 7 then
begin
check:=7;
write(fruit[7]);
end;
if rand = 8 then
begin
check:=8;
write(fruit[8]);
end;
if rand = 9 then
begin
check:=9;
write(fruit[9]);
end;
//right reel
rand:=random(8);
rand:=rand+1;
gotoxy(48,15);
if rand = 1 then
begin
check1:=1;
write(fruit[1]);
end;
if rand = 2 then
begin
check1:=2;
write(fruit[2]);
end;
if rand = 3 then
begin
check1:=3;
write(fruit[3]);
end;
if rand = 4 then
begin
check1:=4;
write(fruit[4]);
end;
if rand = 5 then
begin
check1:=5;
write(fruit[5]);
end;
if rand = 6 then
begin
check1:=6;
write(fruit[6]);
end;
if rand = 7 then
begin
check1:=7;
write(fruit[7]);
end;
if rand = 8 then
begin
check1:=8;
write(fruit[8]);
end;
if rand = 9 then
begin
check1:=9;
write(fruit[9]);
end;
delay(100);
spin:=spin+1;
until spin = 25;

end;

//randomizer for HOLDING
randomize;
hold5050:=random(1)+1;

//randomizer
//left reel
randomize;
rand:=random(8);
rand:=rand+1;
gotoxy(26,15);
if rand = 1 then
begin
checker:=1;
write(fruit[1]);
end;
if rand = 2 then
begin
checker:=2;
write(fruit[2]);
end;
if rand = 3 then
begin
checker:=3;
write(fruit[3]);
end;
if rand = 4 then
begin
checker:=4;
write(fruit[4]);
end;
if rand = 5 then
begin
checker:=5;
write(fruit[5]);
end;
if rand = 6 then
begin
checker:=6;
write(fruit[6]);
end;
if rand = 7 then
begin
checker:=7;
write(fruit[7]);
end;
if rand = 8 then
begin
checker:=8;
write(fruit[8]);
end;
if rand = 9 then
begin
checker:=9;
write(fruit[9]);
end;
//center reel
rand:=random(8);
rand:=rand+1;
gotoxy(37,15);
if rand = 1 then
begin
check:=1;
write(fruit[1]);
end;
if rand = 2 then
begin
check:=2;
write(fruit[2]);
end;
if rand = 3 then
begin
check:=3;
write(fruit[3]);
end;
if rand = 4 then
begin
check:=4;
write(fruit[4]);
end;
if rand = 5 then
begin
check:=5;
write(fruit[5]);
end;
if rand = 6 then
begin
check:=6;
write(fruit[6]);
end;
if rand = 7 then
begin
check:=7;
write(fruit[7]);
end;
if rand = 8 then
begin
check:=8;
write(fruit[8]);
end;
if rand = 9 then
begin
check:=9;
write(fruit[9]);
end;
//right reel
rand:=random(8);
rand:=rand+1;
gotoxy(48,15);
if rand = 1 then
begin
check1:=1;
write(fruit[1]);
end;
if rand = 2 then
begin
check1:=2;
write(fruit[2]);
end;
if rand = 3 then
begin
check1:=3;
write(fruit[3]);
end;
if rand = 4 then
begin
check1:=4;
write(fruit[4]);
end;
if rand = 5 then
begin
check1:=5;
write(fruit[5]);
end;
if rand = 6 then
begin
check1:=6;
write(fruit[6]);
end;
if rand = 7 then
begin
check1:=7;
write(fruit[7]);
end;
if rand = 8 then
begin
check1:=8;
write(fruit[8]);
end;
if rand = 9 then
begin
check1:=9;
write(fruit[9]);
end;

gotoxy(26,15);
//For 3 the same
if checker = check and check1 then
begin
if checker = 1 then
begin
mulitplier:=3;
end;
if checker = 2 then
begin
mulitplier:=4;
end;
if checker = 3 then
begin
mulitplier:=5;
end;
if checker = 4 then
begin
mulitplier:=6;
end;
if checker = 5 then
begin
mulitplier:=7;
end;
if checker = 6 then
begin
mulitplier:=8;
end;
if checker = 7 then
begin
mulitplier:=9;
end;
if checker = 8 then
begin
mulitplier:=10;
end;
if checker = 9 then
begin
mulitplier:=20;
end;
bet:=bet*mulitplier;

end;
//For rell 1 and 2 the same
if checker = check then
begin
if checker = 1 then
begin
mulitplier:=2;
end;
if checker = 2 then
begin
mulitplier:=3;
end;
if checker = 3 then
begin
mulitplier:=4;
end;
if checker = 4 then
begin
mulitplier:=5;
end;
if checker = 5 then
begin
mulitplier:=6;
end;
if checker = 6 then
begin
mulitplier:=7;
end;
if checker = 7 then
begin
mulitplier:=8;
end;
if checker = 8 then
begin
mulitplier:=9;
end;
if checker = 9 then
begin
mulitplier:=10;
end;
bet:=bet*mulitplier;

end;
//For reel 1 and 3 the same
if checker = check1 then
begin
if checker = 1 then
begin
mulitplier:=2;
end;
if checker = 2 then
begin
mulitplier:=3;
end;
if checker = 3 then
begin
mulitplier:=4;
end;
if checker = 4 then
begin
mulitplier:=5;
end;
if checker = 5 then
begin
mulitplier:=6;
end;
if checker = 6 then
begin
mulitplier:=7;
end;
if checker = 7 then
begin
mulitplier:=8;
end;
if checker = 8 then
begin
mulitplier:=9;
end;
if checker = 9 then
begin
mulitplier:=10;
end;
bet:=bet*mulitplier;

end;
//For reel 2 and 3 the same
if check = check1 then
begin
if check = 1 then
begin
mulitplier:=2;
end;
if check = 2 then
begin
mulitplier:=3;
end;
if check = 3 then
begin
mulitplier:=4;
end;
if check = 4 then
begin
mulitplier:=5;
end;
if check = 5 then
begin
mulitplier:=6;
end;
if check = 6 then
begin
mulitplier:=7;
end;
if check = 7 then
begin
mulitplier:=8;
end;
if check = 8 then
begin
mulitplier:=9;
end;
if check = 9 then
begin
mulitplier:=10;
end;
if mulitplier > 1 then
begin
bet:=bet*mulitplier;

end;

end;

semibank:=semibank+bet;
gotoxy(2,10);
cursoron;
write('you have ',bet,' pounds!');
gotoxy(2,11);
write('you have ',winings,' secured');

mulitplier:=1;

until bet = 4;
gotoxy(2,15);

clrscr;
repeat

repeat
gotoxy(35,14);
write('YOU WON ',winings,' POUNDS');
gotoxy(35,14);
delay(100);
write(' ');
delay(100);
endscreenwin:=endscreenwin+1;
until endscreenwin = 20;

gotoxy(35,12);
write('G');
delay(100);
write('A');
delay(100);
write('M');
delay(100);
write('E');
delay(100);
write(' ');
delay(100);
write('O');
delay(100);
write('V');
delay(100);
write('E');
delay(100);
write('R');
delay(1000);
gotoxy(35,12);

write(' ');
delay(01);
if winings > 15000 then
begin

repeat

gotoxy(2,2);
write(' YAhoo YAhoo Yahoo YAhooo YAhooo');
gotoxy(2,4);
write(' YAhoo YAhoo Yahoo YAhooo YAhooo');
gotoxy(2,6);
write(' YAhoo YAhoo Yahoo YAhooo YAhooo');
gotoxy(2,8);
write(' YAhoo YAhoo Yahoo YAhooo YAhooo');
gotoxy(2,10);
write(' YAhoo YAhoo Yahoo YAhooo YAhooo');
gotoxy(2,14);
write(' YAhoo YAhoo Yahoo YAhooo YAhooo');
gotoxy(2,16);
write(' YAhoo YAhoo Yahoo YAhooo YAhooo');
gotoxy(2,18);
write(' YAhoo YAhoo Yahoo YAhooo YAhooo');
gotoxy(2,20);
write(' YAhoo YAhoo Yahoo YAhooo YAhooo');
gotoxy(2,22);
write(' YAhoo YAhoo Yahoo YAhooo YAhooo');
delay(100);
gotoxy(2,2);
write(' ');
gotoxy(2,4);
write(' ');
gotoxy(2,6);
write(' ');
gotoxy(2,8);
write(' ');
gotoxy(2,10);
write(' ');
gotoxy(2,14);
write(' ');
gotoxy(2,16);
write(' ');
gotoxy(2,18);
write(' ');
gotoxy(2,20);
write(' ');
gotoxy(2,22);
write(' ');
yahoo:=yahoo+1;
delay(100);
until yahoo = 100;
end;
endscreen:=endscreen+1;
until endscreen = 9001;
gotoxy(23,5);
write('press enter to quit');

end.

• Here's a short code for what you looking for, it should give you a starting point to expand it to your liking. BTW, break up your program into procedures and/or functions, is bad practice to have everything in one block (also harder to read).
[code][color=Blue]// Compiler FPC (Win) v.2.6.0

{\$mode FPC}{\$asmmode intel}{\$apptype console}
{\$R+} // range checking for debug purposes

uses video,crt;

const fruit:array[0..11] of string[6]=('Error','7','Bar','Bell',
'Melon','Grape','Plum',
'Orange','Lemon','Cherry',
' ','HELD');
reel_list:array[1..7] of shortint=(-3,-2,-1,0,1,2,3); // reel wrap on display
no_of_reels=3; // must be 3 for this implementation
reel_length=45; // i.e. reel stops, must be 45 for this implementation
reel_pos_x=20;reel_pos_y=8; // 1st reel position on screen
reel_width=15;reel_height=17; // reel dimensions (display)
nffs=2; // number of mandatory full turns per spin
nrds=0.5; // next reel extra turn ( so the stop sequence is 1-2-3 )
spin_delay=45; // spin speed adjustment ( in msec's )
random_list=true; // randomize reel, false for debugging
held_col=\$0c; // hold info attribute

var reel:array[1..no_of_reels,1..reel_length] of byte;
reel_pos:array[1..no_of_reels] of byte; // current position of each reel
held:boolean;
h_val:byte; // which reel to hold, only 1 is allowed if none was held before

procedure swap(var a,b:byte); // swaps 2 bytes
begin
if a=b then exit; // no swap if they are equal
a:=a xor b;b:=a xor b;a:=a xor b;
end;

procedure init_reels; // sets up each reel with 1 of 1, 2 of 2's, 3 of 3's etc.
var i,j,k,l:byte; // so 1 occures: 1 in 45, 2: 2 in 45, 3: 3 in 45... etc.
begin
held:=true; // as start, no reels can be hold
h_val:=0; // none
for i:=1 to no_of_reels do begin
l:=1;
reel_pos[i]:=1;
for j:=1 to 9 do
for k:=1 to j do begin
reel[i,l]:=j;
inc(l);
end;
end;
if random_list then
for i:=1 to no_of_reels do
for j:=0 to 3 do // 1024 swaps should be more than enough
for k:=0 to 255 do // randomize order
swap(reel[i,succ(random(reel_length))],reel[i,succ(random(reel_length))]);
end;

procedure outchar(x,y:word;attr:byte;ch:char); // Prints a character with a given text attribute @ x,y
begin
if ((x=0) or (y=0)) then exit;dec(x);dec(y);
videobuf^[y*screenwidth+x]:=word(attr shl 8) or byte(ch); // direct screen memory write
end;

procedure print(x,y:byte;attr:byte;s:string); // same as: gotoxy(x,y);write(s);
var l:byte absolute s;
i:byte;
begin
for i:=1 to l do outchar(pred(x+i),y,attr,s[i]);
end;

procedure disp_reel(i:byte); // display for a reel
var j,k,t,att,x1,y1,x2,y2:byte;
begin
if i>3 then exit else dec(i);
x1:=reel_pos_x+i*reel_width;
y1:=reel_pos_y;
x2:=reel_pos_x+i*reel_width+reel_width-3;
y2:=reel_pos_y+pred(reel_height);
outchar(x1,y1,\$1a,char(\$c9));
outchar(x1,y2,\$1a,char(\$c8));
outchar(x2,y1,\$1a,char(\$bb));
outchar(x2,y2,\$1a,char(\$bc));
for j:=1 to reel_width-4 do begin
outchar(x1+j,y1,\$1a,char(\$cd));
outchar(x1+j,y2,\$1a,char(\$cd));end;
for j:=1 to reel_height-2 do begin
if j=reel_height shr 1 then att:=\$0f else att:=\$1a;
outchar(x1,y1+j,\$1a,char(\$ba));
outchar(x2,y1+j,\$1a,char(\$ba));
for k:=1 to reel_width-4 do
outchar(x1+k,j+y1,att,#32);end;
inc(i); // because dec(i) in the first line
for j:=1 to 7 do begin
t:=reel[i,succ((pred(reel_length shl 1)+reel_pos[i]+reel_list[j]) mod reel_length)];
// if not(t in[1..9]) then t:=0; { <-- debug }
if j=4 then att:=\$0f else att:=\$1a;
print(x1+(6-byte(fruit[t][0]) shr 1),y1+j shl 1,att,fruit[t]);
end;
print((screenwidth-59) shr 1,2,\$0e,'Press: Space - to spin; 1,2,3 - to hold reel; Esc - to Exit');
end;

procedure spin; // animation ( sort of...anyways )
var i,j,k,t:byte;
sv:array[1..no_of_reels] of byte;
nffs_:real;
begin
nffs_:=0;
for i:=1 to no_of_reels do // calc. how much each reel should turn
if h_val<>i then begin // hold feature
sv[i]:=byte(random(reel_length)+nffs*reel_length+round(reel_length*nffs_));
nffs_+=nrds;
end;
t:=sv[no_of_reels];
for i:=1 to t do begin
for j:=1 to no_of_reels do
if h_val<>j then // hold feature
if sv[j]>0 then begin
dec(sv[j]);
if reel_pos[j]=1 then reel_pos[j]:=reel_length else dec(reel_pos[j]);
end;
delay(spin_delay);
for k:=1 to no_of_reels do
if h_val<>k then disp_reel(k); // hold feature
end;
if h_val<>0 then begin // hold feature
h_val:=0;
held:=true;
for i:=1 to no_of_reels do
print(reel_pos_x+pred(i)*reel_width+4,reel_pos_y+succ(reel_height),
held_col,fruit[10]);
end else held:=false;
while keypressed do readkey; // get rid of unpatient user's input
end;

procedure hold(t:byte);
var i:byte;
begin
if held then exit;
if t=h_val then h_val:=0 else h_val:=t;
for i:=1 to no_of_reels do
print(reel_pos_x+pred(i)*reel_width+4,reel_pos_y+succ(reel_height),
held_col,fruit[10+byte(h_val=i)]);
end;

// Use this proc. to get current reel combination status
procedure reel_status(var a,b,c:byte);
begin
a:=reel[1,reel_pos[1]];
b:=reel[2,reel_pos[2]];
c:=reel[3,reel_pos[3]];
end;

// Main loop #################################################################
procedure run;
var i:byte;
ch:char;
begin
for i:=1 to no_of_reels do disp_reel(i);
repeat
case ch of
#32 {space}:spin;
'1','2','3':hold(ord(ch)-48);
#0:readkey; // get rid of extended keycodes
end;end;until ch=#27; // Esc key
end;

// Main #######################################################################
begin
randomize;
initvideo;
clearscreen;
init_reels;
run;
donevideo;
end.
[/color][/code]
• thanks, but i dont understand any of it,which i need to to get the grade, also, when i check if anything is the same(using my current way) can i do something like:

if checker = check1 or check or check1 = check then
begin
//do crap for 2 the same
end else
begin
if checker = check1 and check
begin
//do crap for the 3 the same
end
end
• thanks, but i dont understand any of it,which i need to to get the grade, also, when i check if anything is the same(using my current way) can i do something like:

if checker = check1 or check or check1 = check then
begin
//do crap for 2 the same
end else
begin
if checker = check1 and check
begin
//do crap for the 3 the same
end
end
• : thanks, but i dont understand any of it,which i need to to get the
: grade, also, when i check if anything is the same(using my current
: way) can i do something like:
:
: if checker = check1 or check or check1 = check then...............

Let's say each of the reels return a given value for the current position ( 1 to 9 ), so you got 3 values. Now one of the easiest way to check if there are any winning combinations would be:[code][color=Blue]// assuming a,b,c are the values from the reels, and "t" is word type
t:=100*a+10*b+c; // this gives a unique number for each combination
case t of
111:three_1_in_a_row; { <-- this proc. gets called if they are 3 "1" in a row}
222:<some proc. here>
....
....
999:
...
991..998:< got two 9's on the left, 3rd reel doesn't matter >
//so basically you can list any combinations you can think of
else no_win; // <-- this proc. gets called if there are no listed combinations
end case;
// ... your code here ...
[/color][/code]