I'm learning Pascal in school. I've come across a run time error that's been eluding me these past few days. The error message I get is:
ERROR: line 86, access made to undefined variable
I've been searching t'internet for a while trying to find out some help, alas Pascal as not the most documented of programming languages.
Here is my code:
program WerewolfGameClassAssignment (input, output);
var HelpPrompt, ClassNum, ClassNumCorrect : integer;
HelpResult, ClassInputResult, ClassInputEpicFail : boolean;
procedure Welcome;
begin
writeln('Welcome to Nanor''s Werewolf Game (Or similar) class assigner!');
writeln('Would you like some help?');
writeln('1) Yes!');
writeln('2) No!');
readln(HelpPrompt);
case HelpPrompt of
1 : HelpResult:=True;
2 : HelpResult:=False;
otherwise clrscr; writeln('Invalid input, noob!'); writeln; Welcome;
end;
end;
procedure HelpText;
begin
clrscr;
writeln('Help');
writeln('Text');
writeln('Will');
writeln('Go');
writeln('Here');
end;
procedure ClassInput;
begin
writeln;writeln;
writeln('Please input how many classes there are?');
readln(ClassNum);
clrscr;
end;
procedure ClassInputCorrect;
begin
writeln('You have selected ',ClassNum:2,' classes. Is this correct?');
writeln('1) Yes');
writeln('2) No');
readln(ClassNumCorrect);
if ClassNumCorrect = 1 then
begin
clrscr;
ClassInputResult:=True
end
else if ClassNumCorrect = 2 then
begin
clrscr;
ClassInputResult:=False
end
else
ClassInputEpicFail:=True
end;
begin
Welcome; {Includes help prompt}
if HelpResult = True then
begin
HelpText; {Display help}
ClassInput {Ask how many classes}
end
else
begin
clrscr;
writeln('Too good for help, then?');
ClassInput {How many classses}
end;
ClassInputCorrect; {Validation}
while ((ClassInputResult = False) OR (ClassInputEpicFail = True)) do
begin
ClassInput; {repeat}
ClassInputCorrect
end;
writeln('Continuation text'); {Program doesn't get to here}
end.
I'd appreciate it if this could be kept strictly Pascal and the less said about my boolean variables the better. ;)