home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / STRTMENU.ZIP / STRTMENU.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1988-05-30  |  2.5 KB  |  91 lines

  1. program Menu;
  2. { This program creates a menu from .BAT files.  For each program you wish to
  3.   run, or other action taken, there should be a .BAT file in the directory
  4.   c:\start.  There should be a remarks line in the .BAT file which contains
  5.   a description, 30 characters or less, of the action of the .BAT file.
  6.   If present, it must be the first remarks line in the file.  Also, your
  7.   AUTOEXEC.BAT file must contain a PATH statement that includes the
  8.   directory c:\start.
  9.  
  10.   A typical basic .BAT file would be the following:
  11.  
  12.   echo off
  13.   cls
  14.   rem Lotus 1-2-3
  15.   c:
  16.   cd \lotus
  17.   lotus
  18.  
  19.                                                    John Fistere
  20.                                                    BIX:   johnf
  21.  
  22.   This program is placed in the public domain.  In return, I would appreciate
  23.   knowing if you find it of use to you. }
  24.  
  25. uses
  26.   Dos,Crt;
  27.  
  28. var
  29.   CrtLine,
  30.   DotLoc    : integer;
  31.   Ref       : string[20];
  32.   DirInfo   : SearchRec;
  33.   FileNam   : Text;
  34.   Line      : String[60];
  35.   Entry     : (Left,Right);
  36.  
  37. begin
  38.   ClrScr;
  39.   GoToXY(31,2);
  40.   TextColor(Blue);
  41.   TextBackground(White);
  42.   Writeln('SELECTION MENU');
  43.   TextBackground(Black);
  44.   Writeln('-------------------------------------------------------------------------------');
  45.   Entry := Left;
  46.   FindFirst('c:\start\*.bat',Archive,DirInfo);
  47.   while DosError = 0 do
  48.   begin
  49.     DotLoc := Pos('.',DirInfo.Name);
  50.     Ref := Copy(DirInfo.Name,1,DotLoc -1);
  51.     TextColor(Yellow);
  52.     Write(Ref);
  53.     TextColor(Cyan);
  54.     Assign(FileNam,'c:\start\' + DirInfo.Name);
  55.     Reset(FileNam);
  56.     repeat
  57.       Readln(FileNam,Line);
  58.     until (copy(Line,1,3) = 'rem') or (copy(Line,1,3) = 'REM')
  59.                               or Eof(FileNam);
  60.     CrtLine := WhereY;
  61.     if not Eof(FileNam) then begin
  62.     if Entry = Left then
  63.     begin
  64.       GoToXY(10,CrtLine);
  65.       Write(Copy(Line,5,30));
  66.       GoToXY(41,CrtLine);
  67.       Entry := Right
  68.     end
  69.       else begin
  70.         GoToXY(50,CrtLine);
  71.         Writeln(Copy(Line,5,30));
  72.         Entry := Left;
  73.       end;
  74.     end
  75.       else if Entry = Right then begin
  76.         Entry := Left;
  77.         Writeln;
  78.       end
  79.         else begin
  80.           Entry := Right;
  81.           GoToXY(41,CrtLine);
  82.         end;
  83.     Close(FileNam);
  84.     FindNext(DirInfo);
  85.   end;
  86.   if Entry = Right then writeln;
  87.   TextColor(Blue);
  88.   Writeln('-------------------------------------------------------------------------------');
  89.   TextColor(Yellow);
  90.   Write('Type your selection at the prompt.');
  91. end.