Category : Batch File Utilities - mostly for DOS
Archive   : ABFS.ZIP
Filename : BATMENU.PAS

 
Output of file : BATMENU.PAS contained in archive : ABFS.ZIP
Program BatMenu;
{
Copyright 1990, W.B. Malthouse - M-Squared Systems, Inc.

This program may be copied, distributed, and used by general public,
without limitation on that use, without specific written permission
of the author/copyright holder without limit, provided that:

1. No charge or license fee is made for copies or the use thereof.
2. This copyright notice is included, unmodified, in all such
copies distributed per (1) above.
3. A nominal fee, not to exceed $10.00, may be charged for the
media on which copies are distributed and to cover postage and
handling etc.

This program may be used as the basis for enhanced program development
in whole or part by prior agreement with the author/copyright holder.

W.B. Malthouse
M-Squared Systems, Inc.
5201 George McKay Ct.
Fairfax, VA 22030
(703)-830-4189
}
{$M 8096,0,0}

Uses DOS,CRT,STRS;

Const Help : Boolean = False;
Const BatOpen : Boolean = False;
Const BatFound : Boolean = False;
Const Recursed : Boolean = False;

Var Batfile : String;
Bat : Text;
Nbat : Text;
Hfile : String;
Hf : Text;
Choice : String;
Bline : String;

Procedure Show_Help(Hx:String);

Var Line:String;
Var Ln:Integer;
Var Ok:Boolean;

Procedure ClrHelp;
Var Il:Integer;
Begin
For Il:=5 to 25 do begin
gotoxy(1,il);
Clreol;
End;
Gotoxy(1,6);
End;

Begin
If (Help) and (Hx<>'') then begin
Ok:=false;
Repeat
Assign(Hf,Hx);
{$I-}
Reset(Hf);
{$I+}
If Ioresult<>0 then begin
Textcolor(LightRed);
gotoxy(1,20);
Clreol;
Write('Help file "');
Textcolor(LightGreen+128);
Write(trim(caps(hfile)));
Textcolor(LightRed);
Write('" not found! Enter Help File Name==> ');
Readln(Hx);
textcolor(yellow);
gotoxy(1,20);
Clreol;
If hx='' then OK:=true;
end
Else Begin
Ok:=true;
Textcolor(LightGreen);
Ln:=6;
ClrHelp;
Repeat
Readln(Hf,Line);
Writeln(Line);
Ln:=Ln+1;
If Ln>22 then begin
Gotoxy(1,24);
Write('-More-');
Readln;
ClrHelp;
Ln:=6;
end;
Until Eof(Hf);
Close(Hf);
Gotoxy(1,24);
Write('-End of Help File: '+Hx+'-');
readln;
ClrHelp;
Textcolor(Yellow);
end;
Until Ok;
end;
End;

Procedure Initialize;
Begin
Batfile:='Menu.bat';
Hfile:='Menu.hlp';
Textcolor(Yellow);
Textbackground(Blue);
Clrscr;
Writeln;
Writeln(Center('Welcome to the Advanced Batch File Seminar',78));
Writeln(Center('by',78));
Writeln(Center('W.B. Malthouse',78));
writeln;
End;

Procedure Analyze_Parms;
Var I:Integer;
Var P:String;

Procedure Process_Switch;
Var I,J,L : Integer;
Var W : String;
Begin
If Length(P)>1 then begin
P:=Copy(P,2,Length(P)-1);
L:=Length(P);
Case P[1] of
'H','h' : Begin
Help:=True;
If L>1 then Hfile:=Copy(P,2,L-1);
Show_Help(Hfile);
End;
'N','n': Begin;
Help:=False;
End;
'C','c' :Begin
Writeln;
Writeln(Center('Welcome to the Advanced Batch File Seminar',78));
Writeln(Center('by',78));
Writeln(Center('W.B. Malthouse',78));
writeln;
Help:=True;
If not Recursed then Show_Help(Hfile);
Recursed:=True;
End;
Else Begin
Clrscr;
End;
End;
end;
End;
Begin
If Paramcount>0 then begin
For I:=1 to Paramcount do begin
P:=Caps(Trim(Paramstr(i)));
if P[1]='/' then begin
Process_Switch;
end
Else begin
If I=1 then Batfile:=P
Else begin
Gotoxy(1,23);
Textcolor(LightRed);
Clreol;
Write('Extraneous Parameter==> "');
Textcolor(LightGreen+Blink);
Write(Paramstr(i));
Textcolor(LightRed);
Write('" Ignored!');
gotoxy(1,23);
textcolor(Yellow);
Delay(2000);
Clreol;
end;
end;
end;
end;
End;

Procedure Open_Batfile;
Var OK : Boolean;
Begin
OK:=false;
Repeat
Assign(Bat,Batfile);
{$I-}
Reset(Bat);
{$I+}
If IoResult=0 then begin
OK:=true;
BatOpen:=True;
Assign(Nbat,Copy(Batfile,1,Length(Batfile)-1)+'$');
Rewrite(Nbat);
end
Else Begin
Textcolor(LightRed);
gotoxy(1,23);
Clreol;
Write('Invoking .BAT file "');
Textcolor(LightGreen+128);
Write(trim(caps(batfile)));
Textcolor(LightRed);
Write('" not found! Reenter==> ');
textcolor(yellow);
Readln(batfile);
gotoxy(1,23);
Clreol;
end;
Until (Batfile='') or OK;
End;

Procedure Scan_to_Batmenu;
Begin
Repeat
Readln(Bat,Bline);
Writeln(Nbat,Bline);
Bline:=Caps(Trim(Bline));
If Pos('BATMENU',Bline)=1 then BatFound:=True;
Until Batfound or Eof(Bat)
End;

Procedure Copy_to_Eof;
Begin
If BatOpen and Batfound then begin
Writeln(NBat,Bline);
Writeln(NBat,'@ECHO ÿ');
Writeln(NBat,'@ECHO Press any Key to Return to BATCH Menu Program');
Writeln(NBat,'Pause');
Writeln(NBat,'GOTO TOP');
Close(Nbat);
Close(Bat);
Erase(Bat);
Rename(Nbat,Batfile);
BatOpen:=False;
Clrscr;
end
Else Begin
Clrscr;
end;
End;

Procedure Do_Menus;

Var Parms : String;

Procedure Get_Parms;
Begin
Gotoxy(1,18);
Textcolor(Yellow);
Write('Complete the Blinking Command on The Line Below');
Gotoxy(1,20);
Textcolor(LightGreen+Blink);
Write('?:==> '+PARMS);
Textcolor(Yellow);
Readln(Bline);
Bline:='CALL '+Parms+Bline;
Gotoxy(1,18);
Clreol;
Gotoxy(1,20);
Clreol;
End;

Begin
Parms:='';
Textcolor(Yellow);
Textbackground(Blue);
Clrscr;
Gotoxy(1,2);
Writeln(Center(Caps('M A I N M E N U'),78));
Writeln;
Writeln(' 0. HELP with Menus');
Writeln(' 1. VIEW any File');
Writeln(' 2. DIR');
Writeln(' 3. Editor "E"');
Writeln(' 4. LIST (V.Buerg)');
Writeln(' 5. Prompt for DOS Command');
Writeln(' 6. Sorted Directory');
Writeln(' 7. WD (Which Directory)');
Writeln(' 8. MM (Memory Map)');
Writeln(' 9. OTHER (Specify)');
Writeln;
Gotoxy(1,16);
Textcolor(LightGreen);
Write ('Choice ==> ');
Textcolor(Yellow);
Readln(Choice);
If (Choice='0') or (Choice[1] in ['H','h','?']) then begin
Help:=True;
Show_Help(Hfile);
Do_Menus;
end
Else Begin
If Choice='' then Choice:='*';
Help:=True;
Case Choice[1] of
'1','V','v': Begin {View}
Gotoxy(1,20);
Write('File Name ==> ');
Readln(Parms);
If Parms<>'' then Show_Help(Parms);
Do_Menus;
End;
'2','D','d': Begin {Dir}
Scan_to_Batmenu;
Parms:='DIR ';
Get_Parms;
End;
'3','E','e': Begin {Edit}
Scan_to_Batmenu;
Parms:='E ';
Get_Parms;
End;
'4','L','l': Begin {List}
Scan_to_Batmenu;
Parms:='LIST ';
Get_Parms;
End;
'5','P','p': Begin {Prompt}
Scan_to_Batmenu;
Parms:='COMMAND';
Get_Parms;
End;
'6','S','s': Begin {Sorted Dir}
Scan_to_Batmenu;
Parms:='SD ';
Get_Parms;
End;
'7','W','w': Begin {Which Directory}
Scan_to_Batmenu;
Parms:='WD ';
Get_Parms;
End;
'8','M','m': Begin {Memory Map}
Scan_to_Batmenu;
Parms:='MM ';
Get_Parms;
End;
Else Begin
Scan_to_Batmenu;
Bline:='@Echo ÿ';
Repeat
Gotoxy(1,18);
Write('Enter Desired Full Command Line Below Please');
Gotoxy(1,20);
TextColor(LightGreen+Blink);
Write('?:==> ');
TextColor(Yellow);
Readln(Parms);
if Parms='' then Parms:='Echo *** No User Choice Entered ***';
Until Parms<>'';
Writeln(Nbat,'CALL '+Parms);
End;
End;
If BatFound then begin
Copy_to_Eof;
end
Else Begin
Gotoxy(1,20);
Clreol;
Textcolor(LightRed);
Write('Line Invoking BATMENU Not Found in "'+Batfile+'"  No Action!');
Delay(300);
Copy_to_Eof;
end;
end;
End;

Procedure Close_Batfile;
Begin
If BatOpen then Close(Bat);
Clrscr;
End;

{
M A I N P R O G R A M
}
Begin
Initialize;
Analyze_Parms;
Open_Batfile;
Do_Menus;
Close_Batfile;
End.


  3 Responses to “Category : Batch File Utilities - mostly for DOS
Archive   : ABFS.ZIP
Filename : BATMENU.PAS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/