I'm making a project in Xcode Pascal, the program asks the user if they want to begin then selects seven random in a 'lottery' style game. I wanted to save the numbers into an array so I could select any one of the seven numbers at one time. At the moment I cannot get the program to read the numbers or save them. I know how to use arrays but I cant seem to get them to work for this program. Any help would be greatly appreciated.

program test;
uses
EmptyPlaceHolderUnit;



var
yn : string;
i : integer;
bonus: integer;


procedure start_game (yn: string; i:integer; bonus: integer);
var
subscript: integer;


begin


writeln('Do you want to begin? Please enter Y / N ( Remember to use capital letters! )');       {asks user if they want to begin}
readln(yn);
if (yn = 'Y') then                                      {Will begin program if 'Yes' is entered}
writeln ('The program will now begin') else                                 {Program will end if 'No' is entered}
writeln('You have chosen not to run the program');



if (yn = 'Y') then


begin


writeln (' ');
writeln (' And tonights Lottery Balls are...');
writeln (' ');


randomize;


for i := 1 to 7 do
writeln(random(50),' ');                {Selects 6 random integers from the range 0 - 49}


writeln(i);
end;
end;


begin
start_game(yn, i, bonus);
end.

You have no array in your program - however, your use of random is ok. So, Id argue a difference about using arrays as it seems to be this you're having the issue with.

OK, take it back a stage, how would you assign the numbers 1 through 10 to an array holding 10 integers?

I have a seperate program where I was toying about with an array so I know that works fine. What I did to get the program to work was to get the program to ask the user to enter the numbers back into the prgram. The users input was then stored in the array. I would like this to be tidied up and automatic though.

OK, but write me the code I asked, and then see if the bell tolls and you work out whats missing. as you're close, but without any array concept no its not going to.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.