1.11M Members

Function On Pascal...How Could You Do This?

 
0
 

This Is My Code:-

Begin

  gotoxy(31,1);
  write('Peters Petrol Pump');
  gotoxy(31,2);
  write('==================');

  gotoxy(0,4);
  write('Welcome To Peters Petrol Pump...Here Are Your Options:-');
  gotoxy(5,6);
  write('1. Console');
  gotoxy(5,7);
  write('2. Petrol Pump');
  gotoxy(5,8);
  write('3. Exit');
  gotoxy(0,10);
  write('Please Select An Option...');
  read(StartingAnswer);

  if StartingAnswer =1 then
   Begin
    clrscr;
    gotoxy(30,11);
    write('Under Construction');

     repeat
      gotoxy(30,12);
      write('Press Enter To Exit');
     until Keypressed;

     [B]{Need To Get Back To Main Menu}[/B]

   End;

End.

^^^That Is Just A Little Bit Of My Code.

But what i was wondering was where it says '{Need To Get Back To Main Menu}' how would i get back to that main menu?

i think i have been taught this but i have forgot, looks simple.

Thank You
:)

 
0
 

You need a loop. Like repeat..until or while..do.

You can also check your answers using a case statement.

 
0
 

i already have a repeat loop,

where would i put the second loop

 
0
 

i already have a repeat loop,

where would i put the second loop

 
0
 

Made use from procedures. To menu, use CASE like Duoas sugest You and try some thing lik this:

procedure ProcessMenu;
begin
  clrscr;
  gotoxy(31,1);
  write('Peters Petrol Pump');
  gotoxy(31,2);
  write('==================');

  gotoxy(0,4);
  write('Welcome To Peters Petrol Pump...Here Are Your Options:-');
  gotoxy(5,6);
  write('1. Console');
  gotoxy(5,7);
  write('2. Petrol Pump');
  gotoxy(5,8);
  write('3. Exit');
  gotoxy(0,10);
  write('Please Select An Option...');
  read(StartingAnswer);
end;

Begin
  StartingAnswer := 0;
  While StartingAnswer <> 3 Do
  Begin 
    ProcessMenu;
    Case StartingAnswer Of
      1 :
        Begin
          clrscr;
          gotoxy(30,11);
          write('Under Construction');

          repeat
            gotoxy(30,12);
            write('Press Enter To Exit');
          until Keypressed;
        End;
      2 : 
        Begin
          ...
        End;  
       ...
     End;
  End;
End.

Bye

 
0
 

thanks for the help mate i got it working :D

Question Answered as of 6 Years Ago by Micheus and Duoas
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article