小编hym*_*ode的帖子

从 Pascal 过程中完全退出程序

我的 Pascal 程序在 begin语句和 4 个程序中有一个菜单。在每个程序中,我都会向用户确认他们是否要返回菜单,否则程序将退出,但是每次程序要退出时,它都会再次返回菜单。

procedure quit;
begin
  writeln('<Enter> to quit...');
  readln;
end

procedure error;
begin
  writeln('Error. Try Again...');
  readln;
end;

procedure option1;
begin
  clrscr;
  writeln('this is option 1');
  writeln('would you like to continue? (y/n)');
  readln(confirm);
  if confirm = 'y' then
  begin 
    writeln('something will happen...');
  end;

  if confirm = 'n' then
    begin
      writeln('Return to main menu ? (y/n)');
      readln(option);
      if option = 'y' then
        exit
      else
        quit;
    end;  
end;

procedure option2;
begin
  clrscr; 
  writeln('this is option2');
  writeln('would …
Run Code Online (Sandbox Code Playgroud)

pascal freepascal lazarus

1
推荐指数
1
解决办法
1196
查看次数

标签 统计

freepascal ×1

lazarus ×1

pascal ×1