Pascal/Turbo Pascal - Como hacer un menu

 
Vista:

Como hacer un menu

Publicado por sonny (10 intervenciones) el 19/04/2008 01:58:00
hola a todos y gracias por los aportes....

necesito saber como hacer un menu y que este a su ves se mueva con las teclas del cursor por los items de arriba a abajo y lo contrario...

por ejemplo quiero tener un menu asi:

1. sumar
2. restar
3. multiplicar
4. salir

les ruego me ayuden...... todavia no he empezado por que no se como por eso recurro a ustedes....
gracias de antemano
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Como hacer un menu

Publicado por Roberto Garcia (56 intervenciones) el 21/04/2008 08:56:17
http://mx.geocities.com/antrahxg/pascal/pmf/menus.html

En este enlace vas a encontrar una forma de hacer lo que necesitas
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Como hacer un menu

Publicado por leidy (1 intervención) el 12/09/2008 16:39:05
necesito un menu hecho en turbo pascal o al menos los pasos para crearlo
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Como hacer un menu en pascal

Publicado por milagro (1 intervención) el 07/03/2009 03:00:11
me podrian decir como hacer un menu en pascal
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Como hacer un menu en pascal

Publicado por eL iNqUiEtO.cOm (1 intervención) el 23/02/2010 23:08:21
Program todos;
var proce: Integer;
var respuesta: Char;
Procedure hosp;
Var dias: Integer;
Begin
Writeln ('descuento segun los dias de hospedaje');
Writeln ('capturar dias');
Readln (dias);
IF (dias >=5) AND (dias <10) then
Writeln ('10% de descuento');
IF (dias >=10) AND (dias <15) then
Writeln ('15% de descuento');
IF dias >=15 then
Writeln ('20% de descuento');
END;

Procedure zodiaco;
var sig: Integer;
Begin
Writeln ('captura un numero y te dice el signo del zodiaco');
Writeln ('capturar sig');
Readln (sig);
Case sig of
1: Writeln ('Aries');
2: Writeln ('Tauro');
3: Writeln ('Geminis');
4: Writeln ('Cancer');
5: Writeln ('Leo');
6: Writeln ('Virgo');
7: Writeln ('Libra');
8: Writeln ('Escorpion');
9: Writeln ('Sagitario');
10: Writeln ('Capricornio');
11: Writeln ('Acuario');
12: Writeln ('Piscis');
Else
Writeln ('Fuera de rango');
End;
END;

Procedure veinte;
Var I: Integer;
Begin
Writeln ('Muestra numeros del 1 al 20');
For I:= 1 to 20 do
Writeln (I);
End;

Procedure tabla;
Var tab,I: Integer;
Var K: Integer;
Begin
I:=0;
tab:=0;
Writeln ('Elabora una tabla de multiplicar');
Writeln ('capturar K');
Readln (K);
While I <= 10 do
Begin
Writeln (K, '*', I, '=', tab);
I:=I+1;
tab:= K*I;
End;
END;

Procedure CF;
Var Fahrenheit,Celsius: Real;
Var respuesta: Char;
Begin
Repeat
Writeln ('calcular el equivalente en grados Fahrenheit o Celsius');
Write ('¿desea pasarlo a Fahrenheit o Celsius? F/C: ');
Readln (respuesta);
Writeln (' ');
Until (respuesta='C') or (respuesta='F') or (respuesta='c') or (respuesta='f');
If upcase (respuesta)='F' Then
Begin
Writeln ('introduzca los grados para pasar Fahrenheit: ');
Write ('Celsius: ');
Readln (Celsius);
Fahrenheit:=((9*Celsius)/5)+32;
Write (Fahrenheit:5:2, 'grados Fahrenheit ');
Writeln (' ');
End
Else If upcase (respuesta)='C' Then
Begin
Writeln ('introduzca los grados para pasar a Celsius: ');
Writeln ('Fahrenheit: ');
Readln (Fahrenheit);
Celsius:=((Fahrenheit-32)/9)*5;
Write (Celsius:5:2, 'grados Celsius ');
End;
END;

Begin
Repeat
Writeln ('1:descuento de un hotel');
Writeln ('2:determina el signo del zodiaco');
Writeln ('3:imprime los numeros del 1 al 20');
Writeln ('4:genera una tabla de multiplicar');
Writeln ('5: realiza una conversion de tenperaturas');
Writeln ('capturar proce');
Readln (proce);
Case proce of
1: hosp;
2: zodiaco;
3: veinte;
4: tabla;
5: CF;
Else
Writeln ('no existe');
END;
Writeln ('¿dedeas utilizar otro programa?');
Writeln ('capturar respuesta');
Readln (respuesta);
Until (respuesta='S') or (respuesta='n');
If (respuesta='n') Then
Writeln ('¡Hasta pronto!');
END.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Como hacer un menu en pascal

Publicado por Manuel Henriquez (2 intervenciones) el 08/07/2011 05:39:17
Como crear un menu en free pascal que me permita ver el numero de alumnos de una universidad de 3 pisos donde en cada piso hay 6 salones y puede haber cualquier cantidad de alumnos en cada salon?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Como hacer un menu en pascal

Publicado por ramon (2158 intervenciones) el 09/07/2011 21:43:21
Perdona la pregunta sera un programa no un menú porque el menú solo activa las opciones
del programa no muestra ningún dato por si solo por lo tanto sera un programa con un menú de opciones incorporado dime si es esto para poderte echar una mano.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Como hacer un menu en pascal

Publicado por Manuel Henriquez (2 intervenciones) el 10/07/2011 15:52:52
Correcto tienes razón ramón,yo no se nada de programación pero necesito un programa que me muestre el menú donde muestre el numero de alumnos que hay por cada piso, son 3 pisos que hay en la universidad y en cada piso hay 6 salones, te agradecería que me hecharas una mano en esto.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Como hacer un menu en pascal

Publicado por ramon (2158 intervenciones) el 10/07/2011 22:04:15
{Mira este fragmento de programa y dime si es esto lo que pides esto es el menú comenta si
variamos algo}

program menus;
uses
crt;
type
menu = array[1..6] of string[15];
string15 = string[15];
regalumnos = record
nombre : string[25];
denei : integer;
npiso : integer;
npanta : integer;
end;

var
opcmenu : integer;
men : menu;
tec, tecla : char;
i1, lon, x1, y1, pxs, pys, px, py, long, i, x, y : integer;
sal, salir : boolean;


procedure marcador(xm, ym, t : integer; estado : boolean);
var
pon : integer;
begin
if xm > 70 then
xm := 70;
if ym > 28 then
ym := 28;
if xm < 1 then
xm := 1;
if ym < 1 then
ym := 1;
if estado = true then
begin
for pon := 0 to t - 1 do
begin
gotoxy(xm + pon,ym);write('-');
gotoxy(xm + pon,ym + 2);write('-');
end;
gotoxy(xm - 1,ym + 1);write('|');
gotoxy(xm + t,ym + 1);write('|');
end
else
begin
for pon := 0 to t - 1 do
begin
gotoxy(xm + pon,ym);write(' ');
gotoxy(xm + pon,ym + 2);write(' ');
end;
gotoxy(xm - 1,ym + 1);write(' ');
gotoxy(xm + t,ym + 1);write(' ');
end;
end;

procedure menugeneral(xm, ym : integer;dato1,dato2,dato3,dato4,dato5,dato6 : string15;
longi, datos : integer);
begin
clrscr;
x := xm;
y := ym;
men[1] := dato1;
men[2] := dato2;
men[3] := dato3;
men[4] := dato4;
men[5] := dato5;
men[6] := dato6;
long := longi;
for i := 1 to datos do
begin
gotoxy(x,(y - 1) + i * 2);write(men[i]);
end;
marcador(x,y,long,true);
salir := false;
i := datos;
opcmenu := 1;
gotoxy(xm,ym - 2);write('Use las flechas [ ][ ] y Enter');
gotoxy(xm + 17,ym - 2);write(chr(24));
gotoxy(xm + 20,ym - 2);write(chr(25));
repeat
tecla := readkey;
marcador(x,y,long,false);
if tecla = #80 then
begin
y := y + 2;
if y > datos + ((i - 1) * 2) then
y := datos + ((i - 1) * 2);
opcmenu := opcmenu + 1;
if opcmenu > i then
opcmenu := i;
end;
if tecla = #72 then
begin
y := y - 2;
if y < datos then
y := datos;
opcmenu := opcmenu - 1;
if opcmenu < 1 then
opcmenu := 1;
end;
if tecla = #13 then
begin
case opcmenu of
1 : begin
clrscr;
px := x;
py := y;
gotoxy(10,10);write('Primera Opcion Pulse Enter');
readln;
gotoxy(10,10); ClrEol;
x := xm;
y := ym;
for i := 1 to datos do
begin
gotoxy(x,(y - 1) + i * 2);write(men[i]);
end;
x := px;
y := py;
end;
2 : begin
clrscr;
px := x;
py := y;
gotoxy(10,10);write('Segunda Opcion Pulse Enter');
readln;
gotoxy(10,10); ClrEol;
x := xm;
y := ym;
for i := 1 to datos do
begin
gotoxy(x,(y - 1) + i * 2);write(men[i]);
end;
x := px;
y := py;
end;
3 : begin
clrscr;
px := x;
py := y;
gotoxy(10,10);write('Tercera Opcion Pulse Enter');
readln;
gotoxy(10,10); ClrEol;
x := xm;
y := ym;
for i := 1 to datos do
begin
gotoxy(x,(y - 1) + i * 2);write(men[i]);
end;
x := px;
y := py;
end;
4 : salir := true;
end;
end;
marcador(x,y,long,true);
until salir = true;
end;




begin
menugeneral(4,4,'Entrada Alumno','Datos Por Planta','Datos Por Piso ','Terminar Sesion',' ',' ',16,4);
end.

{dime si te corre bien a ti a mi si}
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Como hacer un menu en pascal

Publicado por ramon (2158 intervenciones) el 11/07/2011 16:19:08
{El programa completo espero te ayude}

program menus;
uses
crt;
type
menu = array[1..6] of string[15];
string15 = string[15];
regalumnos = record
nombre : string[25];
ndenei : integer;
npiso : integer;
nplanta : integer;
end;

string25 = string[25];

var
alumnos : regalumnos;
f : file of regalumnos;
opcmenu : integer;
men : menu;
tec, tecla : char;
i1, lon, x1, y1, pxs, pys, px, py, long, i, x, y : integer;
sal, salir : boolean;


procedure marcador(xm, ym, t : integer; estado : boolean);
var
pon : integer;
begin
if xm > 70 then
xm := 70;
if ym > 28 then
ym := 28;
if xm < 1 then
xm := 1;
if ym < 1 then
ym := 1;
if estado = true then
begin
for pon := 0 to t - 1 do
begin
gotoxy(xm + pon,ym);write('-');
gotoxy(xm + pon,ym + 2);write('-');
end;
gotoxy(xm - 1,ym + 1);write('|');
gotoxy(xm + t,ym + 1);write('|');
end
else
begin
for pon := 0 to t - 1 do
begin
gotoxy(xm + pon,ym);write(' ');
gotoxy(xm + pon,ym + 2);write(' ');
end;
gotoxy(xm - 1,ym + 1);write(' ');
gotoxy(xm + t,ym + 1);write(' ');
end;
end;

function cadena_texto(xt, yt : integer;tipo : char) : string25;
var
dato : string25;
tec : char;
co : integer;
finis : boolean;
begin
co := 1;
fillchar(dato,26,' ');
gotoxy(xt,yt);
finis := false;
repeat
tec := readkey;
if tec <> #27 then
begin
if tipo in['t','T'] then
begin
if tec in[#65..#90,#97..#122,#164,#165,#32] then
begin
dato[co] := upcase(tec);
dato[0] := chr(co);
gotoxy(xt + (co - 1),yt);write(dato[co]);
co := co + 1;
if co > 25 then
co := 25;
end;
end;
if tipo in['n','N'] then
begin
if tec in[#48..#57] then
begin
dato[co] := tec;
dato[0] := chr(co);
gotoxy(xt + (co - 1),yt);write(dato[co]);
co := co + 1;
if co > 25 then
co := 25;
end;
end;
if tec = #8 then
begin
co := co - 1;
if co < 1 then
co := 1;
dato[co] := ' ';
dato[0] := chr(co);
gotoxy(xt + (co - 1),yt);write(dato[co]);
end;
if tec = #13 then
begin
finis := true;
end;
end;
until (finis = true) or (tec = #27);
if finis = true then
begin
cadena_texto := copy(dato,1,length(dato));
end
else
begin
cadena_texto := ' ';
end;
end;



procedure entrada_datos_alumno;
var
pul : char;
final : boolean;
nu, erro : integer;
begin
gotoxy(2,2);write('*** Entre datos Ficha Alumno ***');
gotoxy(2,4);write('Nombre : ');
gotoxy(2,6);write('N§ DNI : ');
gotoxy(2,8);write('N§ Piso : ');
gotoxy(2,10);write('N§ Planta : ');
repeat
alumnos.nombre := cadena_texto(13,4,'t');
nu := 0;
val(cadena_texto(13,6,'n'),nu, erro);
alumnos.ndenei := nu;
nu := 0;
val(cadena_texto(13,8,'n'),nu, erro);
alumnos.npiso := nu;
nu := 0;
val(cadena_texto(13,10,'n'),nu, erro);
alumnos.nplanta := nu;
assign(f,'Archivos.aln');
{$I-} reset(f); {$I+}
if ioresult <> 0 then
begin
rewrite(f);
seek(f,0);
write(f,alumnos);
close(f);
end
else
begin
seek(f,filesize(f));
write(f,alumnos);
close(f);
end;
gotoxy(4,12);write('Desea Entrar mas Fichas [S/N]');
repeat
pul := readkey;
if pul in['n','N'] then
begin
clrscr;
final := true;
end;
if pul in['s','S'] then
begin
gotoxy(13,4); clreol;
gotoxy(13,6); clreol;
gotoxy(13,8); clreol;
gotoxy(13,10); clreol;
gotoxy(4,12); clreol;
end;
until pul in['s','S','n','N']
until final = true;
end;

procedure presenta_alumnos_por_planta(cual : char);
var
hh, erro, contador, planta1, planta : integer;
begin
assign(f,'Archivos.aln');
{$I-} reset(f); {$I+}
if ioresult <> 0 then
begin
clrscr;
gotoxy(5,15);write('*** Error *** No Esiste Archivo de Alumnos',
' [Pulse una tecla]');
repeat until keypressed;
halt(1);
end
else
begin
planta := 0;
planta1 := 0;
if cual in['p','P'] then
begin
gotoxy(2,2);write('*** Alumnos por Planta ***');
gotoxy(2,4);write('Entre N§ Planta : ');
val(cadena_texto(19,4,'n'),planta,erro);
end;
if cual in['s','S'] then
begin
gotoxy(2,2);write('*** Alumnos por Salon y Planta ***');
gotoxy(2,4);write('Entre N§ Salon : ');
val(cadena_texto(18,4,'n'),planta,erro);
gotoxy(2,6);write('Entre N§ Planta : ');
val(cadena_texto(19,6,'n'),planta1,erro);
end;
hh := 0;
contador := 0;
repeat
seek(f,hh);
read(f,alumnos);
if cual in['p','P'] then
begin
if alumnos.nplanta = planta then
begin
contador := contador + 1;
end;
end;
if cual in['s','S'] then
begin
if (alumnos.npiso = planta) and (alumnos.nplanta = planta1) then
begin
contador := contador + 1;
end;
end;
hh := hh + 1;
until hh > filesize(f) - 1;
close(f);
clrscr;
if cual in['p','P'] then
begin
gotoxy(2,2);write('*** El N§ de Alumnos de la Planta [',planta,'] ***');
gotoxy(2,4);write(' ES : ',contador);
end;
if cual in['s','S'] then
begin
gotoxy(2,2);write('*** El N§ de Alumnos del Piso [',planta,'] Salon [',planta1,'] ***');
gotoxy(2,4);write(' ES : ',contador);
end;
gotoxy(2,7);write(' <<< Pulse Enter >>>');
readln;
end;
end;


procedure menugeneral(xm, ym : integer;dato1,dato2,dato3,dato4,dato5,dato6 : string15;
longi, datos : integer);
begin
clrscr;
x := xm;
y := ym;
men[1] := dato1;
men[2] := dato2;
men[3] := dato3;
men[4] := dato4;
men[5] := dato5;
men[6] := dato6;
long := longi;
for i := 1 to datos do
begin
gotoxy(x,(y - 1) + i * 2);write(men[i]);
end;
gotoxy(x,(y - 1) + (i * 2) + 4);write('** MENU GENERAL **');
marcador(x,y,long,true);
salir := false;
i := datos;
opcmenu := 1;
gotoxy(xm,ym - 2);write('Use las flechas [ ][ ] y Enter');
gotoxy(xm + 17,ym - 2);write(chr(24));
gotoxy(xm + 20,ym - 2);write(chr(25));
gotoxy(x + (long + 1) ,y + 1);
repeat
tecla := readkey;
marcador(x,y,long,false);
if tecla = #80 then
begin
y := y + 2;
if y > datos + ((i - 1) * 2) then
y := datos + ((i - 1) * 2);
opcmenu := opcmenu + 1;
if opcmenu > i then
opcmenu := i;
end;
if tecla = #72 then
begin
y := y - 2;
if y < datos then
y := datos;
opcmenu := opcmenu - 1;
if opcmenu < 1 then
opcmenu := 1;
end;
if tecla = #13 then
begin
case opcmenu of
1 : begin
clrscr;
px := x;
py := y;
entrada_datos_alumno;
clrscr;
x := xm;
y := ym;
for i := 1 to datos do
begin
gotoxy(x,(y - 1) + i * 2);write(men[i]);
end;
gotoxy(xm,ym - 2);write('Use las flechas [ ][ ] y Enter');
gotoxy(xm + 17,ym - 2);write(chr(24));
gotoxy(xm + 20,ym - 2);write(chr(25));
gotoxy(x,(y - 1) + (i * 2) + 4);write('** MENU GENERAL **');
x := px;
y := py;
end;
2 : begin
clrscr;
px := x;
py := y;
presenta_alumnos_por_planta('p');
clrscr;
x := xm;
y := ym;
for i := 1 to datos do
begin
gotoxy(x,(y - 1) + i * 2);write(men[i]);
end;
gotoxy(xm,ym - 2);write('Use las flechas [ ][ ] y Enter');
gotoxy(xm + 17,ym - 2);write(chr(24));
gotoxy(xm + 20,ym - 2);write(chr(25));
gotoxy(x,(y - 1) + (i * 2) + 4);write('** MENU GENERAL **');
x := px;
y := py;
end;
3 : begin
clrscr;
px := x;
py := y;
presenta_alumnos_por_planta('s');
clrscr;
x := xm;
y := ym;
for i := 1 to datos do
begin
gotoxy(x,(y - 1) + i * 2);write(men[i]);
end;
gotoxy(xm,ym - 2);write('Use las flechas [ ][ ] y Enter');
gotoxy(xm + 17,ym - 2);write(chr(24));
gotoxy(xm + 20,ym - 2);write(chr(25));
gotoxy(x,(y - 1) + (i * 2) + 4);write('** MENU GENERAL **');
x := px;
y := py;
end;
4 : begin
clrscr;
px := x;
py := y;
assign(f,'Archivos.aln');
{$I-} reset(f); {$I+}
if ioresult <> 0 then
begin
exit;
end
else
begin
gotoxy(2,3);write('*** La Totalidad de Alumnos ***');
gotoxy(2,5);write('Es : ',filesize(f));
gotoxy(2,8);write('<<< Pulse Una Tecla Para Segir >>>');
repeat until keypressed;
close(f);
clrscr;
end;
x := xm;
y := ym;
for i := 1 to datos do
begin
gotoxy(x,(y - 1) + i * 2);write(men[i]);
end;
gotoxy(xm,ym - 2);write('Use las flechas [ ][ ] y Enter');
gotoxy(xm + 17,ym - 2);write(chr(24));
gotoxy(xm + 20,ym - 2);write(chr(25));
gotoxy(x,(y - 1) + (i * 2) + 4);write('** MENU GENERAL **');
x := px;
y := py;
end;
5 : salir := true;
end;
end;
marcador(x,y,long,true);
until salir = true;
end;




begin
menugeneral(4,4,'Entrada Alumno','Datos Por Planta','Datos Por Salon ',
'Alumnos Totales','Terminar Sesion',' ',16,5);
end.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Como hacer un menu en pascal

Publicado por Allisom (1 intervención) el 27/06/2013 15:41:10
como hacer un menu en donde se pueda ejecutar las tablas que yo haya creado.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Como hacer un menu en pascal

Publicado por ramon (2158 intervenciones) el 28/06/2013 17:50:47
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
{Mira Esto en cada zona [Z] pon el procedimiento o función que quieras que se ejecute}
program ejemplo;
uses
      crt;
procedure menu;
  var
     sal : boolean;
     ted, tec : char;
  begin
     sal := false;
    repeat
       clrscr;
       writeln('     ****** Menu General ******');
       writeln;
       writeln('          1 = opcion num 1 ');
       writeln('          2 = opcion num 2');
       writeln('          3 = opcion num 3 ');
       writeln('          4 = opcion num 4 ');
       writeln('          5 = opcion num 5 ');
       writeln('          6 = opcion num 6');
       writeln('          7 = Final ');
       writeln;
       writeln('      >>> Elija Opcion <<<');
       repeat
           tec := readkey;
        if tec in['1','2','3','4','5','6','7'] then
        begin
        end
    else
          begin
                 writeln('  Eleccion Erronea pulse una tecla');
                  readkey;
           end;
       until tec in['1','2','3','4','5','6','7'];
       clrscr;
   case tec of
 '1' : begin
           [Z]
       end;
 '2' : begin
           [Z]
       end;
 '3' : begin
         [Z]
       end;
 '4' : begin
          [Z]
       end;
 '5' : begin
         [Z]
       end;
 '6' : begin
          [Z]
       end;
 '7' : sal := true;
    end;
    until sal = true;
  end;
 
 begin
        menu;
 end.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Como hacer un menu en pascal

Publicado por Jossuan (1 intervención) el 08/11/2017 05:54:31
una pregunta mira que intente utilizar tu ejemplo y me sale un error en '7':sal:=true; me podrías ayudar por favor gracias de antemano.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar