Free Pascal.es

Fuentes de ejemplo para Free Pascal

(* Ejemplo basico en Pascal 5:
   Menu de opciones. Se selecciona pulsando
   las flechas del teclado. *)
 
program ej005;
 
uses crt;
 
const NUMOPCIONES = 5;
 
var opciones: array [1..NUMOPCIONES] of string =
 ('Primera opcion',
  'Segunda opcion',
  'Tercera opcion',
  'Cuarta opcion',
  'Quinta opcion');
 
var
  actual: byte;
  i: byte;
  tecla: char;
 
begin
  actual := 1;
  repeat
    { Borro pantalla }
    clrscr;
    { Escribo opciones }
    for i := 1 to NUMOPCIONES do
      begin
        gotoxy(10, 5 + i*2);
        if i = actual then
          textcolor(14)
        else
          textcolor(7);
        write(opciones[i]);
      end;
    { Espero tecla }
    tecla := readkey;
    { Segun la tecla, subo, bajo o salgo }
    if tecla = chr(0) then { Si es tecla de funcion }
      tecla := readkey;     { tengo que ver el 2o byte }
    if (tecla = chr(72)) and (actual > 1) then
      actual := actual - 1;
    if (tecla = chr(80)) and (actual < NUMOPCIONES) then
      actual := actual + 1;
  until tecla = chr(27); { Hasta pulsar ESC }
end.
 

Novedad!

Buscar

Google
 

   en la Web
   en www.freepascal.es

Qué es

Descargas

Aprende