Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Input prompts calling procedures

Status
Not open for further replies.

Dubbemiah

Programmer
Apr 2, 2005
6
US
(not the whole code)
Code:
program myst;
uses crt;
yn1 : char;  <---variable for yes or no 

(*------------------------*)
procedure enter_name;
begin
      writeln ('Do you like this name?');
      yn1 := GetKey;
      readln (yn1)
      If yn1 = #78 then enter_name;
      if yn1 = #89 then name_pref;
end;
procedure name_pref;
begin
clrscr;
end;
end.
(in the 2nd if statement, i get an Unknown identifier error. how do i make that if statement take me to the name_pref procedure?)

Thanks,
Dubbemiah

 
When name_pref appears after the if statement in the code, then at the time the "if" is compiled, the compiler doesn't yet know about its existence, hence the error.
To deal with this, declare name_pref before the if. The best thing is just to move the entire procedure to above the if statement. If that can't be done, then add a forward declaration:
procedure name_pref; forward;
somewhere before the if, and include the procedure with its full code later as normal.
Good luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top