Jump to content

Recommended Posts

Posted
program menus;
uses CRT;

var opcao: char;


{ Escrevendo rotinas para cada uma das opcoes...
você também pode, ao invés de escrever rotinas, colocar blocos de código
depois dos dois pontos, lembrando de colocar "begin" e "end" no final de
cada um deles }

procedure opcao1;
begin
   clrscr;
   writeln ('Essa é a opção 1');
   readkey;
end;

procedure opcao2;
begin
   clrscr;
   writeln ('Essa é a opção 2');
   readkey;
end;

procedure opcao3;
begin
   clrscr;
   writeln ('Essa é a opção 3');
   readkey;
end;

{ bloco de código principal do programa... }

begin
    repeat
         repeat
              clrscr;
              writeln ('------------ Exemplo de Menu -----------');
              writeln ('[1] Opção 1');
              writeln ('[2] Opção 2');
              writeln ('[3] Opção 3');
              writeln ('[4] Sair');
              opcao := readkey;
         Until (opcao >= '1') and (opcao <= '4');

         Case opcao of
             '1' :  opcao1;
             '2' :  opcao2;   
             '3' :  opcao3;
         end;
     Until (opcao = '4');
end.

Espero que te ajude!

PEACE

  • 11 months later...
  • 4 weeks later...
  • 6 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.