home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / DRAWFLD.ZIP / DRWFIELD.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1986-05-07  |  2.8 KB  |  93 lines

  1. program Draw_Field;
  2. const
  3.   Menu : array[1..7] of string[28] = ('╒══════════════════════════╕',
  4.                                       '│     <<< M E N U >>>      │',
  5.                                       '│                          │',
  6.                                       '│    --- CHOICE # 1 ---    │',
  7.                                       '│    --- CHOICE # 2 ---    │',
  8.                                       '│    --- CHOICE # 3 ---    │',
  9.                                       '╘══════════════════════════╛' );
  10.  
  11. var
  12.   Key : char;
  13.   KeyVal : integer;
  14.   Bar    : integer;
  15. {----------------------------------------------------------------------------}
  16. { DRAWFIELD:                                                                 }
  17. {     ROW, COLUMN = start position of field                                  }
  18. {     SIZE = # of screen positions to set                                    }
  19. {     ATTRIB = Attribute of field to draw                                    }
  20. { Note: This does NOT change the characters appearing in the "field" -- just }
  21. {       the COLOR of the BACKGROUND and FOREGROUND!                          }
  22. {----------------------------------------------------------------------------}
  23. procedure Draw_Field(Row,Column,Size,Attrib : integer);
  24.    external '\turbo\tasm\DRWFIELD.BIN';
  25.  
  26. function GetKey : integer;
  27. var
  28.   Key : array[1..2] of char;
  29.   KeyVal : integer absolute Key;
  30. begin
  31.   KeyVal := 0;
  32.   if Keypressed then
  33.   begin
  34.     read(kbd,Key[1]);
  35.     if keypressed then
  36.     begin
  37.       read(kbd,key[1]);
  38.       Key[2] := #1;
  39.     end
  40.   end;
  41.   GetKey := KeyVal;
  42. end;
  43.  
  44. procedure Display_Menu;
  45. var
  46.   Line : integer;
  47. begin
  48.   ClrScr;
  49.   writeln('    Press ',#24,' to move the highlighted bar upward, or press');
  50.   writeln('    ',#25,' to move the highlighted bar downward.  To "select"');
  51.   writeln('    an "option", press the [ENTER] key.  Press [ESC] to end   ');
  52.   writeln('    this demo.');
  53.   for Line := 1 to 7 do
  54.   begin
  55.     gotoxy(30,Line+9);
  56.     write(Menu[Line]);
  57.   end;
  58. end;
  59.  
  60. begin
  61.   Display_Menu;
  62.   Bar := 1;
  63.   gotoxy(1,25);
  64.   repeat
  65.     Draw_Field(12+Bar,31,26,$70);
  66.     repeat
  67.       KeyVal := GetKey;
  68.     until KeyVal > 0;
  69.     case KeyVal of
  70.       336: begin  {Down Arrow}
  71.              Draw_Field(12+Bar,31,26,$0F);
  72.              Bar := succ(Bar);
  73.              if Bar = 4 then
  74.                Bar := 1;
  75.            end;
  76.       328: begin  {Up Arrow}
  77.              Draw_Field(12+Bar,31,26,$0F);
  78.              Bar := Pred(Bar);
  79.              if Bar = 0 then
  80.                Bar := 3;
  81.            end;
  82.        13: begin
  83.              gotoxy(30,25);
  84.              write('Option #',Bar,' chosen!');
  85.            end;
  86.        27: begin
  87.              gotoxy(30,25);
  88.              write('*** Program concluded! ***');
  89.            end;
  90.     end;
  91.   until KeyVal = 27;
  92. end.
  93.