home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Jason Aller Floppy Collection
/
153.img
/
TELES.ZIP
/
MENUEDT.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1988-07-14
|
10KB
|
429 lines
{$R-} {Range checking off}
{$B+} {Boolean complete evaluation on}
{$S+} {Stack checking on}
{$I+} {I/O checking on}
{$N-} {No numeric coprocessor}
{$V-}
Unit MenuEdt;
Interface
Uses
Crt,
Common;
Procedure Menu_Edit;
Var
C:Integer;
Changed:Boolean;
Exist:Boolean;
Implementation
function cstr(i:integer):astr;
var c:astr;
begin
str(i,c); cstr:=c;
end;
function mln(i:astr; l:integer):astr;
begin
while length(i)<l do i:=i+' ';
mln:=i;
end;
function mn(i,l:integer):astr;
begin
mn:=mln(cstr(i),l);
end;
procedure makenewfile;
var f:text;
begin
cl(3);
prompt(n+' is a new file. Creating...');
assign(f,n);
rewrite(f);
writeln(f,'NULL');
writeln(f,'Command? ');
writeln(f,'?');
writeln(f,'0');
writeln(f,'77');
writeln(f,'0');
writeln(f,' ');
close(f);
print('Ok');
end;
procedure inputn(var i:integer; ml:integer);
var s:astr;
begin
str(i,s);
input1(s,ml,false);
i:=value(s);
end;
procedure cmdline;
begin
end;
{procedure cmdline;
var x,y:integer; i:astr;
begin
getdir(0,i);
x:=wherex; y:=wherey;
window(1,1,80,25);
cl(0); textbackground(1);
clreol; gotoxy(1,1);
prompt('Commands on Menu: ',c,' │ Editing: ',n,' │ Active Directory: '+i);
window(1,2,80,25);
tb(0); gotoxy(x,y);
end;}
procedure display;
var i:integer; done,abort:boolean;
begin
nl; nl;
done:=false; abort:=false;
cl(0);
printacr('NN Command MSL Type Option data Option String',abort,next);
cl(9);
printacr('-- -------------- --- ---- ----------- ----------------------------------------',abort,next);
i:=1;
while (i<=c) and (not abort) do
begin
printacr(mn(i,3)+mln(cmdl[i],15)+mn(msl[i],4)+mn(cmdtype[i],5)+
mn(optdata[i],12)+optstr[i],abort,next);
i:=i+1;
end;
end;
procedure editcmd;
var i,x,z:integer; r:char; s:astr;
begin
display;
nl;
cl(3);
prompt('Enter # to Edit : ');
cl(9);
inputn(i,2);
if (i>0) and (i<c+1) then
repeat
nl;
cl(5); print('CMD Information');
nl;
cl(3); prompt('1> ');
cl(3);
prompt('Command String :');
cl(9);
print(cmdl[i]);
cl(3); prompt('2> ');
cl(3);
prompt('Security Level :');
cl(9);
print(cstr(msl[i]));
cl(3); prompt('3> ');
cl(3);
prompt('Command Type :');
cl(9);
print(cstr(cmdtype[i]));
cl(3); prompt('4> ');
cl(3);
prompt('Optional Data :');
cl(9);
print(cstr(optdata[i]));
cl(3); prompt('5> ');
cl(3);
prompt('Optional String :');
cl(9);
print(optstr[i]);
nl;
cl(7);
prompt('Enter Selection [1-5] or Q=Quit : ');
cl(9);
onek(r,'12345Q');
if r='1' then begin
nl; cl(3); prompt('Enter new command string : '); cl(9);
input(s,14); cmdl[i]:=s;
end;
if r='2' then begin
nl; cl(3); prompt('Enter new Security Level : '); cl(9);
inputn(z,3); msl[i]:=z;
end;
if r='3' then begin
nl; cl(3); prompt('Enter new Command Type : '); cl(9);
inputn(z,3); cmdtype[i]:=z;
end;
if r='4' then begin
nl; cl(3); prompt('Enter new Optional Data : '); cl(9);
inputn(z,3); optdata[i]:=z;
end;
if r='5' then begin
nl; cl(3); prompt('Enter new Optional String : '); cl(9);
inputl(s,40); optstr[i]:=s;
end;
until (r='Q') or hangup;
end;
procedure deletecmd;
var i:integer; x:integer;
begin
display;
nl;
cl(3);prompt('Enter # to delete : ');
cl(9);
inputn(i,2);
if (i>0) and (i<c+1) then begin
for x:=i+1 to c do begin
cmdl[x-1]:=cmdl[x];
msl[x-1]:=msl[x];
cmdtype[x-1]:=cmdtype[x];
optdata[x-1]:=optdata[x];
optstr[x-1]:=optstr[x];
end;
c:=c-1;
cmdline;
end;
end;
procedure addcmd;
var s:astr; z:integer;
begin
if c<30 then begin
nl;
nl;
cl(7);
print('Please enter following information');
nl;
cl(3);
prompt('Command string : '); cl(9); input(s,14);
if s<>'' then begin
c:=c+1; cmdl[c]:=s;
cl(3);
prompt('Security Level : '); cl(9); inputn(z,3); msl[c]:=z;
cl(3);
prompt('Command Type : '); cl(9); inputn(z,3); cmdtype[c]:=z;
cl(3);
prompt('Optional Data : '); cl(9); inputn(z,3); optdata[c]:=z;
cl(3);
prompt('Optional String : '); cl(9); inputl(s,40); optstr[c]:=s;
cl(7);
prompt('Cmd #'+cstr(c)+' added.');
cmdline;
end;
end else writeln('You are limited to 30 commands per menu.');
end;
procedure insertcmd;
var z,ic,x:integer; s:astr;
begin
if c<30 then begin
nl; nl;
cl(9);Prompt('Insert before (1-'+cstr(c)+') : '); cl(0);
input(s,2); if s<>'' then begin
ic:=value(s);
c:=c+1;
for x:=c downto ic do begin
cmdl[x]:=cmdl[x-1];
msl[x]:=msl[x-1];
cmdtype[x]:=cmdtype[x-1];
optdata[x]:=optdata[x-1];
optstr[x]:=optstr[x-1];
end;
cl(7);
print('Please enter following information');
nl;
cl(3);
prompt('Command string : '); cl(9); input(s,14);
if s<>'' then begin
cmdl[ic]:=s;
cl(3);
prompt('Security Level : '); cl(9); inputn(z,3); msl[ic]:=z;
cl(3);
prompt('Command Type : '); cl(9); inputn(z,3); cmdtype[ic]:=z;
cl(3);
prompt('Optional Data : '); cl(9); inputn(z,3); optdata[ic]:=z;
cl(3);
prompt('Optional String : '); cl(9); inputl(s,40); optstr[ic]:=s;
cl(7);
prompt('Cmd #'+cstr(ic)+' added.');
end;
end;
end else writeln('You already have 30 commands, delete some to make room.');
end;
procedure savemenu;
var filv:text; i:integer;
begin
nl; nl; cl(3);
assign(filv,n);
rewrite(filv);
writeln(filv,directive);
writeln(filv,menuprompt);
for i:=1 to c do begin
writeln(filv,cmdl[i]);
writeln(filv,msl[i]);
writeln(filv,cmdtype[i]);
writeln(filv,optdata[i]);
writeln(filv,optstr[i]);
end;
close(filv); print('Menu saved.');
changed:=false;
end;
procedure asksave;
var save:boolean; r:char;
begin
nl;
cl(3);
prompt(n+' not saved. Save (Y/N) ? ');
cl(9);
if yn then save:=true else save:=false;
if save then savemenu;
end;
procedure readin;
begin
c:=0;
assign(filv,n);
{$I-} reset(filv); {$I+}
if ioresult<>0 then begin print(n+' does not exist.'); exist:=false; end else
BEGIN
changed:=false;
readln(filv,directive);
readln(filv,menuprompt);
repeat
c:=c+1;
readln(filv,cmdl[c]);
readln(filv,msl[c]);
readln(filv,cmdtype[c]);
readln(filv,optdata[c]);
readln(filv,optstr[c]);
until (eof(filv));
close(filv);
cmdline;
EXIST:=TRUE;
END;
end;
procedure workfile;
var s:astr;
begin
nl;
if changed then asksave;
cl(3);
prompt('Enter new work file : ');
cl(9);
input(s,8);
if s<>'' then begin
N:=s;
n:=systat.menupath+n+'.MNU';
readin;
if exist=false then begin makenewfile; readin; end;
end;
end;
procedure directives;
var s:astr; R:Char;
begin
repeat
nl;
cl(7);
prompt('Current Directives:');
nl;
cl(3);
prompt('1> ');
cl(3);
print('File Printed : '+directive);
cl(3);
prompt('2> ');
cl(3);
print('Menu Prompt : '+menuprompt);
nl; cl(3);
prompt('Enter Selection [1-2] or Q to quit : ');
cl(9);
onek(r,'12Q');
if (r='1') then begin
print('Enter file printed. DO NOT mark a extension if you want it to');
print('also print ANSI files to ansi users.'); nl;
cl(3); prompt('File Printed : ');
cl(9); input(s,12); directive:=s;
end;
if r='2' then begin
print('Enter new menu prompt. Use "^" for a command marker');
print('Use ^n where n is 0-9 for color, and @ for cmd letters in');
print('strings.');
nl;
cl(3); prompt('Menu Prompt : ');
cl(9);
inputl(s,50); menuprompt:=s;
end;
until (r='Q') or (hangup);
end;
procedure menuhelp;
Begin
nl; nl;
cl(5);
prompt('W');cl(0);prompt('ork file ');cl(5);
prompt('A');cl(0);prompt('dd cmd to menu');
nl;cl(5);
prompt('D');cl(0);prompt('isplay list ');cl(5);
prompt('Q');cl(0);prompt('uit to BBS'); NL; cl(5);
prompt('S');cl(0);prompt('ave menu file ');cl(5);
prompt('?');cl(0);prompt('This menu'); NL; cl(5);
prompt('T');cl(0);prompt('erminate cmd ');cl(5);
prompt('E');cl(0);prompt('dit a cmd'); nl; cl(5);
prompt('X');cl(0);prompt('Menu prompts '); cl(5);
prompt('I');cl(0);prompt('nsert a cmd');
nl; nl;
end;
procedure menu;
var r:char;
begin
repeat
nl;
cl(4);
prompt('MenuEdit Cmd (?=Menu) ->'); cl(2);
ONEK(R,'IDAWSTEXQ?');
if (r='A') or (r='T') or (r='I') or (r='E') or (r='X') then changed:=true;
if r='?' then menuhelp;
if r='D' then display;
if r='A' then addcmd;
if r='I' then insertcmd;
if r='W' then workfile;
if r='S' then savemenu;
if r='T' then deletecmd;
if r='E' then editcmd;
IF R='X' THEN directives;
until (r='Q') or (hangup);
if changed then asksave;
end;
Procedure Menu_Edit;
var i:integer; r:char;
begin
cls;
changed:=false;
for i:=1 to 50 do begin
cmdl[i]:='';
msl[i]:=0;
cmdtype[i]:=0;
optdata[i]:=0;
optstr[i]:='';
end;
n:=systat.menupath+'MAIN.MNU'; readin;
clrscr;
cmdline;
nl;
cl(9);
prompt('Telegard BBS MenuEdit -- V 1.0 By Carl Mueller');
nl;
menuhelp;
menu;
end;
END.