home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / TURBOPAS / EXECMENU.ZIP / EXECMENU.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1988-04-08  |  47.6 KB  |  1,076 lines

  1. {$R-}
  2. {$B+}
  3. {$S+}
  4. {$I+}
  5. {$N-}
  6. {$M 16384,0,65635}
  7.  
  8.  
  9. PROGRAM executive_menu;
  10.  
  11. uses Crt,
  12.      Dos,
  13.      Graph;
  14.  
  15.      CONST                      {1234567890123456789012345678901234567890}
  16.           filler           =    '                                        ';
  17.           drive            =    'C:' ;  { drive for bat files }
  18.           max_batch        =    10;    { max number of lines in the batch file }
  19.           max_menus        =    8;     { max number of menus }
  20.           max_options      =    8;     { max number of options per menu }
  21.           max_text_len     =    40;    { max length of each text line in .DEF file }
  22.           bat_filename     =    'temp.bat';   { temporary batch file name }
  23.           menu_filename    =    'execmenu.def';   { the menu definition file }
  24.  
  25.      TYPE
  26.           line             =    STRING [80] ; { gp line length }
  27.           string6          =    STRING [6] ; { for good time and good date functions }
  28.           string9          =    STRING [9] ; { for fulldate function }
  29.           entry            =    STRING [max_text_len] ; { for strings from .DEF file }
  30.           video_code       =    INTEGER;
  31.  
  32.      VAR
  33.           menufile         :    TEXT ;  { the .DEF file }
  34.           menus            :    ARRAY [1..max_menus,0..max_options] OF entry ;
  35.           helps            :    ARRAY [1..max_menus,1..max_options] OF entry ;
  36.           pw               :    ARRAY [1..max_menus,1..max_options] OF STRING [30] ;
  37.           password         :    STRING [30] ; { user input }
  38.           pw_ok            :    BOOLEAN ;
  39.           num_menus        :    0..max_menus ;
  40.           current_menu     :    0..max_menus ;
  41.           menu_option      :    0..max_options ;
  42.           num_options      :    ARRAY [0..max_menus] OF 0..max_options ;
  43.           tempbatfile      :    TEXT ;  { performs bat cmds then calls autobat }
  44.           bats             :    ARRAY [1..max_menus,1..max_options,1..max_batch] OF entry;
  45.           oldtime          :    STRING [8] ;
  46.           time             :    STRING [8] ;
  47.           date             :    STRING [9] ;
  48.           olddate          :    STRING [9] ;
  49.           doit             :    BOOLEAN ;
  50.           lpoint           :    STRING [2] ;
  51.           cursor           :    CHAR;
  52.           i                :    INTEGER;
  53.           ch               :    CHAR ;
  54.           dummy            :    char;
  55.           GRAPHICSMODE     :    integer;
  56.           LAST_OPTION_FILE :    text;
  57.  
  58.  
  59. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  60.  
  61.  
  62.      procedure check_for_graphics;
  63.  
  64.           var
  65.             GRAPHMODE : integer;
  66.  
  67.         begin
  68.             GRAPHICSMODE:=0;       {DETECT}
  69.             DetectGraph (GRAPHICSMODE, GRAPHMODE);
  70.           end;
  71.  
  72. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  73.  
  74.     procedure set_video (code:video_code);
  75.  
  76.           begin
  77.             case GRAPHICSMODE of
  78.                     1 : begin                    {CGA graphics adaptor}
  79.                            case code of
  80.                             0 :  begin        {off}
  81.                                     Textcolor (blue);
  82.                                     Textbackground (blue);
  83.                                 end;
  84.                                   1 :  begin        {normal}
  85.                                             Textcolor (white);
  86.                                             Textbackground (blue);
  87.                                        end;
  88.                                   2 :  begin        {highlighted}
  89.                                             Textcolor (white);
  90.                                             Textbackground (cyan);
  91.                                        end;
  92.                                   3 :  begin        {important one}
  93.                                             Textcolor (lightred);
  94.                                             Textbackground (white);
  95.                                        end;
  96.                                   4 :  begin        {real important one}
  97.                                             Textcolor (white);
  98.                                             Textbackground (red);
  99.                                        end;
  100.                                  end;
  101.                       end;
  102.              2,3,4,9,10 : begin                    {MCGA, EGA, EGA64, VGA, and PC3270 graphics adaptors}
  103.                                case code of
  104.                             0 :  begin        {off}
  105.                                     Textcolor (blue);
  106.                                     Textbackground (blue);
  107.                                 end;
  108.                                   1 :  begin        {normal}
  109.                                             Textcolor (white);
  110.                                             Textbackground (blue);
  111.                                        end;
  112.                                   2 :  begin        {highlighted}
  113.                                             Textcolor (red);
  114.                                             Textbackground (white);
  115.                                        end;
  116.                                   3 :  begin        {important one}
  117.                                             Textcolor (lightred);
  118.                                             Textbackground (blue);
  119.                                        end;
  120.                                   4 :  begin        {real important one}
  121.                                             Textcolor (yellow);
  122.                                             Textbackground (red);
  123.                                        end;
  124.                                  end;
  125.                       end;
  126.                                              else   begin                    {NO graphics adaptor or not supported}
  127.                            case code of
  128.                             0 :  begin        {off}
  129.                                     Textcolor (black);
  130.                                     Textbackground (black);
  131.                                 end;
  132.                                   1 :  begin        {normal}
  133.                                             Textcolor (white);
  134.                                             Textbackground (black);
  135.                                        end;
  136.                                   2 :  begin        {reverse}
  137.                                             Textcolor (black);
  138.                                             Textbackground (white);
  139.                                        end;
  140.                                   3 :  begin        {normal blink}
  141.                                             Textcolor (white+blink);
  142.                                             Textbackground (black);
  143.                                        end;
  144.                                   4 :  begin        {reverse blink}
  145.                                             Textcolor (black+blink);
  146.                                             Textbackground (white);
  147.                                        end;
  148.                                  end;
  149.                        end;
  150.                end;
  151.           end;
  152.  
  153.  
  154. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  155.  
  156.     procedure set_change_video (code:video_code);
  157.  
  158.           begin
  159.             case GRAPHICSMODE of
  160.                     1 : begin                    {CGA graphics adaptor}
  161.                            case code of
  162.                                   10 :  begin
  163.                                             Textcolor (black);
  164.                                             Textbackground (blue);
  165.                                        end;
  166.                                   11 :  begin
  167.                                             Textcolor (red);
  168.                                             Textbackground (blue);
  169.                                        end;
  170.                                   12 :  begin
  171.                                             Textcolor (green);
  172.                                             Textbackground (white);
  173.                                        end;
  174.                                   13 :  begin
  175.                                             Textcolor (white);
  176.                                             Textbackground (blue);
  177.                                        end;
  178.                                  end;
  179.                       end;
  180.              2,3,4,9,10 : begin                    {MCGA, EGA, EGA64, VGA, and PC3270 graphics adaptors}
  181.                                case code of
  182.                             0 :  begin        {off}
  183.                                     Textcolor (blue);
  184.                                     Textbackground (blue);
  185.                                 end;
  186.                                   1 :  begin
  187.                                             Textcolor (black);
  188.                                             Textbackground (blue);
  189.                                        end;
  190.                                   2 :  begin
  191.                                             Textcolor (lightgreen);
  192.                                             Textbackground (blue);
  193.                                        end;
  194.                                   3 :  begin
  195.                                             Textcolor (red);
  196.                                             Textbackground (blue);
  197.                                        end;
  198.                                   4 :  begin
  199.                                             Textcolor (yellow);
  200.                                             Textbackground (blue);
  201.                                        end;
  202.                                   5 :  begin
  203.                                             Textcolor (cyan);
  204.                                             Textbackground (blue);
  205.                                        end;
  206.                                   6 :  begin
  207.                                             Textcolor (lightred);
  208.                                             Textbackground (blue);
  209.                                        end;
  210.                                   7 :  begin
  211.                                             Textcolor (lightgray);
  212.                                             Textbackground (blue);
  213.                                        end;
  214.                                   8 :  begin
  215.                                             Textcolor (lightmagenta);
  216.                                             Textbackground (blue);
  217.                                        end;
  218.                                   9 :  begin
  219.                                             Textcolor (brown);
  220.                                             Textbackground (blue);
  221.                                        end;
  222.                                  10 :  begin
  223.                                             Textcolor (lightblue);
  224.                                             Textbackground (blue);
  225.                                        end;
  226.                                  11 :  begin
  227.                                             Textcolor (magenta);
  228.                                             Textbackground (blue);
  229.                                        end;
  230.                                  12 :  begin
  231.                                             Textcolor (lightcyan);
  232.                                             Textbackground (blue);
  233.                                        end;
  234.                                  13 :  begin
  235.                                             Textcolor (green);
  236.                                             Textbackground (blue);
  237.                                        end;
  238.                                  14 :  begin
  239.                                             Textcolor (darkgray);
  240.                                             Textbackground (blue);
  241.                                        end;
  242.                                  15 :  begin
  243.                                             Textcolor (white);
  244.                                             Textbackground (blue);
  245.                                        end;
  246.                                  21 :  begin
  247.                                             Textcolor (black);
  248.                                             Textbackground (white);
  249.                                        end;
  250.                                  22 :  begin
  251.                                             Textcolor (lightgreen);
  252.                                             Textbackground (white);
  253.                                        end;
  254.                                  23 :  begin
  255.                                             Textcolor (red);
  256.                                             Textbackground (white);
  257.                                        end;
  258.                                  24 :  begin
  259.                                             Textcolor (yellow);
  260.                                             Textbackground (white);
  261.                                        end;
  262.                                  25 :  begin
  263.                                             Textcolor (cyan);
  264.                                             Textbackground (white);
  265.                                        end;
  266.                                  26 :  begin
  267.                                             Textcolor (lightred);
  268.                                             Textbackground (white);
  269.                                        end;
  270.                                  27 :  begin
  271.                                             Textcolor (blue);
  272.                                             Textbackground (white);
  273.                                        end;
  274.                                  28 :  begin
  275.                                             Textcolor (lightmagenta);
  276.                                             Textbackground (white);
  277.                                        end;
  278.                                  29 :  begin
  279.                                             Textcolor (brown);
  280.                                             Textbackground (white);
  281.                                        end;
  282.                                  30 :  begin
  283.                                             Textcolor (lightblue);
  284.                                             Textbackground (white);
  285.                                        end;
  286.                                  31 :  begin
  287.                                             Textcolor (magenta);
  288.                                             Textbackground (white);
  289.                                        end;
  290.                                  32 :  begin
  291.                                             Textcolor (lightcyan);
  292.                                             Textbackground (white);
  293.                                        end;
  294.                                  33 :  begin
  295.                                             Textcolor (green);
  296.                                             Textbackground (white);
  297.                                        end;
  298.                                  34 :  begin
  299.                                             Textcolor (darkgray);
  300.                                             Textbackground (white);
  301.                                        end;
  302.                                  35 :  begin
  303.                                             Textcolor (white);
  304.                                             Textbackground (white);
  305.                                        end;
  306.                                  end;
  307.                       end;
  308.  
  309.                end;
  310.           end;
  311.  
  312. {-----------------------------------------------------------------------}
  313.  
  314.           function gooddate: string6;
  315.  
  316.                { Returns a 6 character STRING WITH the date in the format: YYMMDD      }
  317.  
  318.                TYPE
  319.                      Registers   =   RECORD
  320.                                          ax,bx,cx,dx,bp,si,di,ds,es,flags: word;
  321.                                    END;
  322.  
  323.                VAR
  324.                     recpack            : Registers;
  325.                     aday, amonth, ayear: STRING[2];
  326.                     day,month          : BYTE;
  327.                     year               : INTEGER;
  328.  
  329.                BEGIN
  330.                     recpack.ax := $2a shl 8;
  331.                     MsDos(Dos.Registers(recpack));
  332.                     year:=recpack.cx;
  333.                     day:=recpack.dx mod 256;
  334.                     month:=recpack.dx shr 8;
  335.                     year:=year-1900;
  336.                     STR(day:2,aday); STR(month:2,amonth); STR(year:2,ayear);
  337.                     IF day <10 THEN aday :='0'+aday[2];
  338.                     IF month<10 THEN amonth:='0'+amonth[2];
  339.                     IF year<10 THEN ayear:='0'+ayear[2];
  340.                     gooddate:= ayear + amonth + aday;
  341.                END;
  342.  
  343. {----------------------------------------------------------------------}
  344.  
  345.           function goodtime: string6;
  346.  
  347.                {returns the an 6 character string with the time in the format:
  348.                 HHMMSS, with leading zeros when needed.}
  349.  
  350.                TYPE
  351.                     Registers = record
  352.                                     ax,bx,cx,dx,bp,si,di,ds,es,flags: word;
  353.                               end;
  354.  
  355.                VAR
  356.                     recpack      : Registers;                {record for MsDos call}
  357.                     yst          : string[4];
  358.                     mst,dst      : string[2];
  359.                     ahr,amin,asec: string[2];
  360.                     hr,min,sec   : BYTE;
  361.  
  362.                BEGIN
  363.                     with recpack do
  364.                         begin
  365.                              ax := $2c shl 8;
  366.                         end;
  367.                     MsDos(Dos.Registers(recpack));                        { call function }
  368.                     with recpack do
  369.                         begin
  370.                              sec:=dx shr 8;
  371.                              min:=cx mod 256;
  372.                              hr:=cx shr 8;
  373.                         end;
  374.                    str(hr:2,  ahr);
  375.                    str(min:2, amin);
  376.                    str(sec:2, asec);
  377.                    if hr <10 then ahr :='0'+copy(ahr, 2,1);
  378.                    if min<10 then amin:='0'+copy(amin,2,1);
  379.                    if sec<10 then asec:='0'+copy(asec,2,1);
  380.                    goodtime:=ahr + amin + asec;
  381.                END;
  382.  
  383. {-------------------------------------------------------------------------}
  384.  
  385.      FUNCTION fulldate : string9;
  386.  
  387.           CONST
  388.                months  :    Array [1..12] Of String[3] =  ('JAN','FEB','MAR','APR','MAY','JUN',
  389.                                                            'JUL','AUG','SEP','OCT','NOV','DEC');
  390.  
  391.           VAR
  392.                tmp     :    String[9];
  393.                i,j     :    Integer;
  394.  
  395.           BEGIN
  396.                tmp := gooddate;
  397.                Val (Copy (tmp,3,2),i,j);
  398.                fulldate := tmp[5] + tmp[6] + ' ' + months[i] + ' ' + tmp[1] + tmp[2];
  399.           END;
  400.  
  401. {*--------------------------------------------------------------------------*}
  402.  
  403. PROCEDURE read_definition_file;
  404.  
  405.      CONST                      {12345678901234567890123456789012345678901234567890}
  406.           spaces           =    '                                        ' ;
  407.  
  408.      VAR
  409.           i,j,k,l          :    INTEGER;
  410.           num_menu_counter :    integer;
  411.           num_options_counter:  integer;
  412.           num_batch_counter:    integer;
  413.           code,ch          :    CHAR;
  414.           temp             :    line ;
  415.           num_bat_lines    :    INTEGER ;
  416.  
  417.      BEGIN
  418.           ASSIGN (menufile,drive+menu_filename) ;
  419.           RESET (menufile);
  420.           num_bat_lines := 0 ;
  421.           num_menus := 0;
  422.           FOR num_menu_counter := 1 TO max_menus DO
  423.             BEGIN
  424.                  num_options[num_menu_counter] := 0;
  425.                  FOR num_options_counter := 0 TO max_options DO
  426.                     menus [num_menu_counter,num_options_counter] :=  '';
  427.                  FOR num_options_counter := 1 TO max_options DO
  428.                     BEGIN
  429.                          pw [num_menu_counter,num_options_counter] := '' ;
  430.                          helps [num_menu_counter,num_options_counter] := '' ;
  431.                          FOR num_batch_counter := 1 TO max_batch DO
  432.                             bats [num_menu_counter,num_options_counter,num_batch_counter] := '' ;
  433.                     END;
  434.             END;
  435.           num_bat_lines:=0;
  436.           num_menus:=0;
  437.           num_options[1]:=0;
  438.           WHILE NOT EOF(menufile) DO
  439.             BEGIN
  440.                  READ (menufile,code);
  441.                  while (code = '.') do
  442.                     begin
  443.                          READLN (menufile);
  444.                          Read (menufile,code);
  445.                     end;
  446.                  temp := '';
  447.                  WHILE NOT EOLN(menufile) DO
  448.                       BEGIN
  449.                            READ (menufile,ch) ;
  450.                            temp := temp + ch ;
  451.                       END ;
  452.                  READLN (menufile) ;
  453.                  case code of
  454.                    '+': BEGIN
  455.                              num_bat_lines := num_bat_lines + 1 ;
  456.                              bats [num_menus,num_options[num_menus],num_bat_lines] := temp ;
  457.                         END;
  458.                    '%': BEGIN
  459.                              num_menus := num_menus + 1 ;
  460.                              menus [num_menus,0] := temp ;
  461.                         END;
  462.                    '*': BEGIN
  463.                              num_bat_lines := 0 ;
  464.                              num_options[num_menus] := num_options[num_menus] + 1 ;
  465.                              menus [num_menus,num_options[num_menus]] := temp ;
  466.                         END;
  467.                    '?': helps [num_menus,num_options[num_menus]] := temp;
  468.                    '^': pw [num_menus,num_options[num_menus]] := temp ;
  469.                    end; {of case statement}
  470.             END;  { while not eof menufile }
  471.             CLOSE (menufile);
  472.        FOR i := 1 TO num_menus DO  {center title and help lines }
  473.           BEGIN
  474.                l := (max_text_len - LENGTH (menus[i,0])) DIV 2 ;
  475.                menus[i,0] := COPY (spaces,1,l) + menus[i,0] + spaces ;
  476.                FOR j := 1 TO num_options[i] DO
  477.                   BEGIN
  478.                        l := (max_text_len - LENGTH (helps[i,j])) DIV 2 ;
  479.                        helps[i,j] := COPY (spaces,1,l) + helps[i,j] + spaces ;
  480.                   END ;
  481.           END ;
  482.      END;
  483.  
  484. {-----------------------------------------------------------------------}
  485.  
  486.      PROCEDURE display_borders;
  487.  
  488.           VAR
  489.                i       :    INTEGER ;
  490.                x,q     :    INTEGER;
  491.                g       :    INTEGER;
  492.                l,lf,rt :    INTEGER;
  493.  
  494.           BEGIN
  495.                set_video(1);
  496.                CLRSCR ;
  497.                GotoXY(5,1);
  498.                WRITE('╔') ;
  499.                FOR q := 6 TO 74 DO
  500.                    WRITE('═');
  501.                WRITE('╗');
  502.                GOTOXY (5,2);
  503.                WRITE('║  ');
  504.                set_video(2);
  505.                GOTOXY (24,2);
  506.                WRITE (' POINT AND SHOOT MENU SYSTEM ');
  507.                set_video(1);
  508.                GOTOXY (75,2);
  509.                WRITE('║');
  510.                GOTOXY (5,3);
  511.                WRITE('╠');
  512.                FOR q := 6 TO 74 DO
  513.                WRITE('═');
  514.                WRITE('╣');
  515.                FOR q := 4 TO 21 DO
  516.                   BEGIN
  517.                        GotoXY(5,q);
  518.                        WRITE('║');
  519.                        GotoXY(75,q);
  520.                        WRITE('║');
  521.                   END;
  522.                GOTOXY (5,22);
  523.                WRITE('╠');
  524.                FOR q := 6 TO 18 DO
  525.                   WRITE('═');
  526.                WRITE('╡');
  527.                GOTOXY (60,22);
  528.                WRITE ('╞');
  529.                FOR q := 61 TO 74 DO
  530.                   WRITE('═');
  531.                WRITE ('╣');
  532.                GotoXY(5,23);
  533.                WRITE('║');
  534.                GotoXY(75,23);
  535.                WRITE('║');
  536.                GotoXY(5,24);
  537.                WRITE('╚');
  538.                FOR q := 6 TO 74 DO
  539.                   WRITE('═');
  540.                WRITE('╝');
  541.                WINDOW (6,4,74,23);
  542.           END;
  543.  
  544. {---------------------------------------------------------------------------------------------------------------------------}
  545.  
  546.           procedure display_borders_through_color (in_color:integer);
  547.  
  548.                VAR
  549.                     q       :    integer;
  550.  
  551.                begin
  552.                     window (1,1,80,25);
  553.                 set_change_video(in_color);
  554.                     GotoXY(5,1);
  555.                     write('╔');
  556.                     for q := 6 TO 74 do
  557.                         write('═') ;
  558.                     write('╗');
  559.                     GotoXY (5,2);
  560.                     write('║  ');
  561.                     GotoXY (24,2);
  562.                 set_change_video(in_color+20);
  563.                     WRITE (' POINT AND SHOOT MENU SYSTEM ');
  564.                 set_change_video(in_color);
  565.                     GotoXY (75,2);
  566.                     write('║');
  567.                     GotoXY (5,3);
  568.                     write('╠');
  569.                     for q := 6 TO 74 do
  570.                         write('═');
  571.                     write('╣') ;
  572.                     for q := 4 TO 21 do
  573.                        begin
  574.                             GotoXY (5,q);
  575.                             write ('║');
  576.                             GotoXY (75,q);
  577.                             write ('║');
  578.                        end;
  579.                     GotoXY (5,22);
  580.                     write ('╠');
  581.                     for q := 6 TO 18 do
  582.                        write('═');
  583.                     write ('╡');
  584.                     GotoXY (60,22);
  585.                     write ('╞');
  586.                     for q := 61 TO 74 do
  587.                        write ('═');
  588.                     write ('╣');
  589.                     GotoXY (5,23);
  590.                     write ('║');
  591.                     GotoXY (75,23);
  592.                     write ('║');
  593.                     GotoXY (5,24);
  594.                     write ('╚');
  595.                     for q := 6 TO 74 do
  596.                        write ('═');
  597.                     write ('╝');
  598.                     window (6,4,74,23) ;
  599.                     GOTOXY (29,20) ;
  600.                     WRITE ('MENU ',current_menu:1,' OF ',num_menus:1) ;
  601.                end;
  602.  
  603. {-----------------------------------------------------------------------}
  604.  
  605.      PROCEDURE print_help ;             { print the help line }
  606.  
  607.           BEGIN
  608.                GOTOXY (15,19);
  609.                set_video(2);
  610.                WRITE (helps [current_menu,menu_option]);
  611.                set_video(1);
  612.           END ;
  613.  
  614. {-----------------------------------------------------------------------}
  615.  
  616.      PROCEDURE display_menu;
  617.  
  618.           VAR
  619.              i   :    INTEGER ;
  620.  
  621.           BEGIN
  622.                WINDOW  (6,4,74,21);
  623.                set_video(1);
  624.                CLRSCR ;
  625.                TEXTCOLOR (yellow) ;
  626.                GOTOXY (14,1);
  627.                WRITE (menus[current_menu,0]);
  628.                set_video(1);
  629.                FOR i :=  1 TO (num_options[current_menu])  DO
  630.                   BEGIN
  631.                        if menus[current_menu,i]<>menus[current_menu,0]
  632.                          then begin
  633.                                    GOTOXY (22,i*2+1);
  634.                                    WRITE (i:2,' - ',menus[current_menu,i]) ;
  635.                               end;
  636.                   END;
  637.                WINDOW (6,4,74,23);
  638.                GOTOXY (29,20) ;
  639.                WRITE ('MENU ',current_menu:1,' OF ',num_menus:1) ;
  640.                print_help ;
  641.           END;
  642.  
  643. {-----------------------------------------------------------------------}
  644.  
  645.      PROCEDURE point ;
  646.  
  647.           BEGIN
  648.                GotoXY(20,(menu_option)*2+1);  {12}
  649.                set_video(3);
  650.                WRITE ('  ',menu_option:2,' - ',menus[current_menu,menu_option]+'   ') ;
  651.           END ;
  652.  
  653. {-----------------------------------------------------------------------}
  654.  
  655.      PROCEDURE clear_point ;
  656.  
  657.           BEGIN
  658.                GotoXY (20,(menu_option)*2+1);
  659.                set_video(1);
  660.                write ('  ',menu_option:2,' - ',menus[current_menu,menu_option]+'   ');
  661.           END ;
  662.  
  663. {-----------------------------------------------------------------------}
  664.  
  665.           procedure see_what;
  666.  
  667.                var
  668.                     OPTION_HOLDER    : integer;
  669.                     FIRST_CHARACTER  : char;
  670.                     SECOND_CHARACTER : char;
  671.  
  672.                begin
  673.                 set_video(1);
  674.                     FIRST_CHARACTER:=' ';
  675.                     SECOND_CHARACTER:=' ';
  676.                 FIRST_CHARACTER:=ReadKey;
  677.                     FIRST_CHARACTER:=chr(ord(FIRST_CHARACTER));
  678.                     i := ORD (FIRST_CHARACTER) - ORD ('0') ;
  679.                     IF i IN [1..num_options[current_menu]]
  680.                        THEN BEGIN
  681.                                  doit := TRUE ;
  682.                                  clear_point ;
  683.                                  menu_option := i ;
  684.                                  point ;
  685.                             END
  686.                     else case FIRST_CHARACTER of
  687.                            #13 : begin
  688.                                       if (SECOND_CHARACTER=#0)
  689.                                          then begin
  690.                                                    FIRST_CHARACTER:=SECOND_CHARACTER;
  691.                                                    SECOND_CHARACTER:=ReadKey;
  692.                                               end;
  693.                                  end;
  694.                            #0  : begin
  695.                                       SECOND_CHARACTER:=ReadKey;
  696.                                       OPTION_HOLDER:=0;
  697.                                       case SECOND_CHARACTER of
  698.                                        #80 : begin                        {down arrow}
  699.                                                   clear_point;
  700.                                                   OPTION_HOLDER:=menu_option+1;
  701.                                                   if OPTION_HOLDER > num_options[current_menu]
  702.                                                      then menu_option:=1
  703.                                                      else menu_option:=OPTION_HOLDER;
  704.                                                   point;
  705.                                              end;
  706.                                        #72 : begin                        {up arrow}
  707.                                                   clear_point;
  708.                                                   menu_option:= menu_option-1;
  709.                                                   if menu_option < 1
  710.                                                      then menu_option := num_options[current_menu];
  711.                                                   point;
  712.                                              end;
  713.                                #77,#68,#73 : begin                       {right arrow,F10,pgup}
  714.                                                   current_menu := (current_menu MOD num_menus) + 1;
  715.                                                   display_menu;
  716.                                                   menu_option := 1;
  717.                                                   point;
  718.                                               END ;
  719.                                 #75,#67,#81 : begin                      {left arrow,f9,pgdn}
  720.                                                    current_menu := current_menu - 1;
  721.                                                    IF current_menu < 1
  722.                                                    THEN current_menu := num_menus;
  723.                                                    display_menu;
  724.                                                    menu_option := 1;
  725.                                                    point;
  726.                                               END;
  727.                                        #71 : begin                        {home}
  728.                                                   clear_point;
  729.                                                   current_menu:=1;
  730.                                                   display_menu;
  731.                                                   menu_option:=1;
  732.                                                   point;
  733.                                              END;
  734.                                        #79 : begin                        {end}
  735.                                                   clear_point;
  736.                                                   current_menu:=num_menus;
  737.                                                   display_menu;
  738.                                                   menu_option:=1;
  739.                                                   point;
  740.                                              END;
  741.                                        #71 : begin                        {home}
  742.                                                   clear_point;
  743.                                                   menu_option:=1;
  744.                                                   point;
  745.                                              end;
  746.                                        #79 : begin                        {end}
  747.                                                   clear_point;
  748.                                                   menu_option:=num_options[current_menu];
  749.                                                   point;
  750.                                              end;
  751.                                        #59 : begin                        {F1}
  752.                                                   IF 1 IN [1..num_options[current_menu]]
  753.                                                      THEN BEGIN
  754.                                                                doit := TRUE;
  755.                                                                clear_point;
  756.                                                                menu_option := 1;
  757.                                                                point;
  758.                                                           END;
  759.                                              end;
  760.                                        #60 : begin                        {F2}
  761.                                                   IF 2 IN [1..num_options[current_menu]]
  762.                                                      THEN BEGIN
  763.                                                                doit := TRUE;
  764.                                                                clear_point;
  765.                                                                menu_option := 2;
  766.                                                                point;
  767.                                                           END;
  768.                                              end;
  769.                                        #61 : begin                        {F3}
  770.                                                   IF 3 IN [1..num_options[current_menu]]
  771.                                                      THEN BEGIN
  772.                                                                doit := TRUE;
  773.                                                                clear_point;
  774.                                                                menu_option := 3;
  775.                                                                point;
  776.                                                           END;
  777.                                              end;
  778.                                        #62 : begin                        {F4}
  779.                                                   IF 4 IN [1..num_options[current_menu]]
  780.                                                      THEN BEGIN
  781.                                                                doit := TRUE;
  782.                                                                clear_point;
  783.                                                                menu_option := 4;
  784.                                                                point;
  785.                                                           END;
  786.                                              end;
  787.                                        #63 : begin                        {F5}
  788.                                                   IF 5 IN [1..num_options[current_menu]]
  789.                                                      THEN BEGIN
  790.                                                                doit := TRUE;
  791.                                                                clear_point;
  792.                                                                menu_option := 5;
  793.                                                                point;
  794.                                                           END;
  795.                                              end;
  796.                                        #64 : begin                        {F6}
  797.                                                   IF 6 IN [1..num_options[current_menu]]
  798.                                                      THEN BEGIN
  799.                                                                doit := TRUE;
  800.                                                                clear_point;
  801.                                                                menu_option := 6;
  802.                                                                point;
  803.                                                           END;
  804.                                              end;
  805.                                        #65 : begin                        {F7}
  806.                                                   IF 7 IN [1..num_options[current_menu]]
  807.                                                      THEN BEGIN
  808.                                                                doit := TRUE;
  809.                                                                clear_point;
  810.                                                                menu_option := 7;
  811.                                                                point;
  812.                                                           END;
  813.                                              end;
  814.                                        #66 : begin
  815.                                                   IF 8 IN [1..num_options[current_menu]]
  816.                                                      THEN BEGIN
  817.                                                                doit := TRUE;
  818.                                                                clear_point;
  819.                                                                menu_option := 8;
  820.                                                                point;
  821.                                                           END;
  822.                                              end;
  823.                                         end; {of 2nd case statement}
  824.                                  end; {of #0 statement}
  825.                          end;  {of 1st case statement}
  826.                     if FIRST_CHARACTER = #13
  827.                        then doit := TRUE
  828.                        else begin
  829.                                  doit := FALSE;
  830.                                  print_help;
  831.                                  GotoXY (2,10);
  832.                            set_video(0);
  833.                                  write (' ');
  834.                                  GotoXY (2,10);
  835.                             end;
  836.                end;
  837.  
  838. {---------------------------------------------------------------------------------------------------------------------------}
  839.  
  840.      PROCEDURE write_batch_file ;
  841.  
  842.           VAR
  843.                i    :    INTEGER ;
  844.  
  845.           BEGIN
  846.                ASSIGN (tempbatfile,drive+bat_filename) ;
  847.                REWRITE (tempbatfile) ;
  848.                FOR i := 1 TO max_batch DO
  849.                    IF bats [current_menu,menu_option,i] <> '' THEN
  850.                    WRITELN (tempbatfile,bats [current_menu,menu_option,i]);
  851.                CLOSE (tempbatfile) ;
  852.           END;
  853.  
  854. {-----------------------------------------------------------------------}
  855.  
  856.      PROCEDURE startup_the_clock;
  857.  
  858.           BEGIN
  859.                time := goodtime;
  860.                INSERT (':',time,3);
  861.                INSERT (':',time,6);
  862.                GOTOXY (59,20);
  863.                set_video(1);
  864.                WRITE (time);
  865.                DATE:=FULLDATE;
  866.                OLDDATE:=DATE;
  867.                GOTOXY (3,20);
  868.                WRITE (date);
  869.                oldtime := goodtime ;
  870.           END;
  871.  
  872. {-----------------------------------------------------------------------}
  873.  
  874.      PROCEDURE update_clock;
  875.  
  876.           BEGIN
  877.                time := goodtime;
  878.                DATE := FULLDATE;
  879.                IF time <> oldtime
  880.                   THEN BEGIN
  881.                             INSERT (':',time,3);
  882.                             INSERT (':',time,6);
  883.                             GOTOXY (59,20);
  884.                             set_video(1);
  885.                             WRITE (time);
  886.                             IF DATE <> OLDDATE
  887.                                THEN BEGIN
  888.                                          GOTOXY (3,20);
  889.                                          WRITE (DATE);
  890.                                          OLDDATE:=DATE;
  891.                                     END;
  892.                             oldtime := goodtime;
  893.                             GOTOXY (2,10);
  894.                             set_video(0);
  895.                             WRITE (' ');
  896.                             GOTOXY (2,10);
  897.                        END;
  898.           END;
  899.  
  900. {-----------------------------------------------------------------------}
  901.  
  902.      PROCEDURE do_password ;
  903.  
  904.           BEGIN
  905.                TEXTCOLOR (WHITE);
  906.                password := '';
  907.                WRITE (CHR(7),CHR(7));
  908.                GOTOXY (2,20);
  909.                WRITE ('  ENTER PASSWORD  ');
  910.                GOTOXY (22,20);
  911.                TEXTBACKGROUND (LIGHTMAGENTA);
  912.                TEXTCOLOR (BLACK);
  913.                WRITE ('>');
  914.                TEXTCOLOR (YELLOW);
  915.                WRITE ('.............................. ') ;
  916.                GOTOXY (23,20);
  917.                TEXTCOLOR (CYAN);
  918.                ch:=ReadKey;
  919.                WHILE ch <> CHR (13) DO
  920.                     BEGIN
  921.                          WRITE ('*') ;
  922.                          password := password + UPCASE (ch) ;
  923.                          ch:=ReadKey;
  924.                     END ;
  925.               pw_ok := (password = pw [current_menu,menu_option]);
  926.               IF NOT pw_ok
  927.                  THEN BEGIN
  928.                            doit := FALSE;
  929.                            TEXTBACKGROUND (LIGHTMAGENTA);
  930.                            GOTOXY (23,20);
  931.                            TEXTCOLOR (CYAN+BLINK);
  932.                            WRITE ('      INCORRECT PASSWORD      ');
  933.                            WRITE (CHR(7),CHR(7));
  934.                            DELAY (500);
  935.                            WRITE (CHR(7),CHR(7));
  936.                            DELAY (3000);
  937.                       END
  938.                  ELSE
  939.                       BEGIN
  940.                            GOTOXY (23,20);
  941.                            WRITE ('      PASSWORD ACCEPTED       ');
  942.                            DELAY (2000);
  943.                       END;
  944.                set_video(1);
  945.                GOTOXY (2,20);
  946.                WRITE (' ':56);
  947.                gotoxy (2,20);
  948.                oldtime := '';
  949.                update_clock;
  950.                if NOT pw_ok
  951.                  then begin
  952.                            display_menu;
  953.                            point;
  954.                       end;
  955.           END;
  956.  
  957. {-----------------------------------------------------------------------}
  958.  
  959.      PROCEDURE hide_the_cursor;
  960.  
  961.           begin
  962.                set_video(0);
  963.                GotoXY (2,2);
  964.                write (' ');
  965.                GotoXY (2,2);
  966.           end;
  967.  
  968. {----------------------------------------------------------------------}
  969.  
  970.      PROCEDURE monitor_menu;
  971.  
  972.           var
  973.                COUNTER : integer;
  974.  
  975.           BEGIN
  976.                COUNTER:=1;
  977.                REPEAT
  978.                      IF KEYPRESSED
  979.                         THEN BEGIN
  980.                                   see_what;
  981.                                   IF doit
  982.                                      THEN BEGIN
  983.                                                pw_ok := TRUE;
  984.                                                IF pw [current_menu,menu_option] <> ''
  985.                                                   THEN do_password;
  986.                                                IF pw_ok
  987.                                                   THEN BEGIN
  988.                                                             write_batch_file;
  989.                                                             GotoXY (1,25);
  990.                                                             write ('Batchfile being written');
  991.                                                             EXIT ;  { exit to complete the last command in auto.bat }
  992.                                                        END;
  993.                                           END;
  994.                              END
  995.                         ELSE begin
  996.                                        update_clock;
  997.                                        case GRAPHICSMODE of
  998.                                         1,2,3,4,9,10 : begin
  999.                                                             if ((COUNTER = 2000) or
  1000.                                                                 (COUNTER = 4000) or (COUNTER = 6000) or
  1001.                                                                 (COUNTER = 8000) or (COUNTER = 10000) or
  1002.                                                                 (COUNTER = 12000) or (COUNTER = 14000) or
  1003.                                                                 (COUNTER = 16000) or (COUNTER = 18000) or
  1004.                                                                 (COUNTER = 20000) or (COUNTER = 22000) or
  1005.                                                                 (COUNTER = 24000) or (COUNTER = 26000) or
  1006.                                                                 (COUNTER = 28000) or (COUNTER = 30000))
  1007.                                                                 then begin
  1008.                                                                           display_borders_through_color (COUNTER div 2000);
  1009.                                                                           hide_the_cursor;
  1010.                                                                      end;
  1011.                                                             if COUNTER=32000
  1012.                                                                then COUNTER:=2000
  1013.                                                                else inc(COUNTER);
  1014.                                                        end;
  1015.                                        end;
  1016.                             END;
  1017.                UNTIL FALSE ;  { do forever ... }
  1018.           END ;
  1019.  
  1020. {-----------------------------------------------------------------------}
  1021.  
  1022.      PROCEDURE all_done;
  1023.  
  1024.           BEGIN
  1025.                rewrite (LAST_OPTION_FILE);
  1026.                writeln (LAST_OPTION_FILE,current_menu);
  1027.                writeln (LAST_OPTION_FILE,menu_option);
  1028.                set_video(1);
  1029.                Window (1,1,80,25);
  1030.                CLRSCR;
  1031.           END ;
  1032.  
  1033. {-----------------------------------------------------------------------}
  1034.  
  1035.      PROCEDURE setup;
  1036.  
  1037.           BEGIN
  1038.                oldtime := '';     { used to see if its time to update the clock }
  1039.                current_menu := 1;
  1040.                menu_option := 1;
  1041.                lpoint := '═' + CHR (16);  { the pointer }
  1042.                doit := FALSE;
  1043.           END;
  1044.  
  1045. {-----------------------------------------------------------------------}
  1046. {                       M A I N   P R O G R A M                         }
  1047. {-----------------------------------------------------------------------}
  1048.  
  1049. BEGIN
  1050.      Assign (LAST_OPTION_FILE,'LASTEXEC.DAT');
  1051.      {$I-}
  1052.      Reset (LAST_OPTION_FILE);
  1053.      {$I+}
  1054.      if IOresult=0
  1055.         then begin
  1056.                   Readln (LAST_OPTION_FILE,current_menu);
  1057.                   Readln (LAST_OPTION_FILE,menu_option);
  1058.              end
  1059.         else begin
  1060.                   current_menu:=1;
  1061.                   menu_option:=1;
  1062.              end;
  1063.      check_for_graphics;
  1064.      read_definition_file;
  1065.      display_borders;
  1066.      startup_the_clock;
  1067.      display_menu;
  1068.      point ;
  1069.      hide_the_cursor;
  1070.      monitor_menu ;
  1071.      all_done ;
  1072.      close (LAST_OPTION_FILE);
  1073. END.
  1074.  
  1075. {-----------------------------------------------------------------------}
  1076.