home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Jason Aller Floppy Collection
/
153.img
/
TELES.ZIP
/
MENUEDIT.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1988-05-19
|
10KB
|
448 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 MenuEdit;
Interface
Uses
Crt,
Common;
Procedure Menu_Edit;
Var
C:Integer;
Changed:Boolean;
Exist:Boolean;
Implementation
procedure tc(i:integer);
begin
textcolor(i);
end;
procedure tb(i:integer);
begin
textbackground(i);
end;
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
textcolor(11);
write(n+' is a new file. Creating...');
assign(f,n);
rewrite(f);
writeln(f,'NULL');
writeln(f,'Command? ');
writeln(f,'C');
writeln(f,'10');
writeln(f,'2');
writeln(f,'0');
writeln(f,'Reason:');
close(f);
writeln('Ok');
end;
procedure input1(var i:astr; ml:integer; tf:boolean);
var cp:integer;
cc:char;
r:real;
begin
cp:=1;
repeat
cc:=readkey;
if not tf then cc:=upcase(cc);
if (cc>=' ') and (cc<chr(127)) then
if cp<=ml then begin
i[cp]:=cc;
cp:=cp+1;
write(cc);
end else else case ord(cc) of
8:if cp>1 then begin
cc:=chr(8);
write(cc);write(' '); write(cc);
cp:=cp-1;
end;
21,24:while cp<>1 do begin
cp:=cp-1;
write(#8);write(' ');write(#8);
end;
end;
until (cc=#13) or (cc=#14);
i[0]:=chr(cp-1);
writeln;
end;
procedure input(var i:astr; ml:integer); (* Input uppercase only *)
begin
input1(i,ml,false);
end;
procedure inputl(var i:astr; ml:integer); (* Input lower & upper case *)
begin
input1(i,ml,true);
end;
function value(I:astr):integer;
var n,n1:integer;
begin
val(i,n,n1);
if n1<>0 then begin
i:=copy(i,1,n1-1);
val(i,n,n1)
end;
value:=n;
if i='' then value:=0;
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;
var x,y:integer; i:astr;
begin
getdir(0,i);
x:=wherex; y:=wherey;
window(1,1,80,25);
tc(15); textbackground(1);
clreol; gotoxy(1,1);
write('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;
begin
writeln; writeln;
tc(15);
writeln('NN Command MSL Type Option data Option String');
tc(9);
writeln('-- -------------- --- ---- ----------- ----------------------------------------');
tc(3);
for i:=1 to c do writeln(mn(i,3),mln(cmdl[i],15),mn(msl[i],4),mn(cmdtype[i],5),mn(optdata[i],12),optstr[i]);
end;
procedure editcmd;
var i,x,z:integer; r:char; s:astr;
begin
display;
writeln;
tc(11);
write('Enter # to Edit : ');
tc(10);
inputn(i,2);
repeat
writeln;
tc(14); writeln('CMD Information');
writeln;
tc(11); write('1> ');
tc(3);
write('Command String :');
tc(10);
writeln(cmdl[i]);
tc(11); write('2> ');
tc(3);
write('Security Level :');
tc(10);
writeln(msl[i]);
tc(11); write('3> ');
tc(3);
write('Command Type :');
tc(10);
writeln(cmdtype[i]);
tc(11); write('4> ');
tc(3);
write('Optional Data :');
tc(10);
writeln(optdata[i]);
tc(11); write('5> ');
tc(3);
write('Optional String :');
tc(10);
writeln(optstr[i]);
writeln;
tc(12);
write('Enter Selection [1-5] or Q=Quit : ');
tc(10);
r:=readkey; r:=upcase(r);
write(r);
if r='1' then begin
writeln; tc(11); write('Enter new command string : '); tc(10);
input(s,14); cmdl[i]:=s;
end;
if r='2' then begin
writeln; tc(11); write('Enter new Security Level : '); tc(10);
inputn(z,3); msl[i]:=z;
end;
if r='3' then begin
writeln; tc(11); write('Enter new Command Type : '); tc(10);
inputn(z,3); cmdtype[i]:=z;
end;
if r='4' then begin
writeln; tc(11); write('Enter new Optional Data : '); tc(10);
inputn(z,3); optdata[i]:=z;
end;
if r='5' then begin
writeln; tc(11); write('Enter new Optional String : '); tc(10);
inputl(s,40); optstr[i]:=s;
end;
until (r='Q');
end;
procedure deletecmd;
var i:integer; x:integer;
begin
display;
writeln;
tc(11);Write('Enter # to delete : ');
tc(10);
inputn(i,2);
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;
procedure addcmd;
var s:astr; z:integer;
begin
c:=c+1;
writeln;
writeln;
tc(12);
writeln('Please enter following information');
writeln;
tc(11);
write('Command string : '); textcolor(10); input(s,14); cmdl[c]:=s;
tc(11);
write('Security Level : '); textcolor(10); inputn(z,3); msl[c]:=z;
tc(11);
write('Command Type : '); textcolor(10); inputn(z,3); cmdtype[c]:=z;
tc(11);
write('Optional Data : '); textcolor(10); inputn(z,3); optdata[c]:=z;
tc(11);
write('Optional String : '); textcolor(10); inputl(s,40); optstr[c]:=s;
tc(12);
write('Cmd #',c,' added.');
cmdline;
end;
procedure savemenu;
var filv:text; i:integer;
begin
writeln; writeln; tc(11);
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); writeln('Menu saved.');
changed:=false;
end;
procedure asksave;
var save:boolean; r:char;
begin
writeln;
tc(11);
write(n+' not saved. Save (Y/N) ? ');
tc(10);
repeat
r:=readkey;
r:=upcase(r);
if r='Y' then save:=true;
if r='N' then save:=false;
until (r='Y') or (r='N');
if r='Y' then writeln('Yes');
if r='N' then writeln('No');
if save then savemenu;
end;
procedure readin;
begin
c:=0;
assign(filv,n);
{$I-} reset(filv); {$I+}
if ioresult<>0 then begin writeln(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));
cmdline;
EXIST:=TRUE;
END;
end;
procedure workfile;
var s:astr;
begin
writeln;
if changed then asksave;
textcolor(11);
write('Enter new work file : ');
textcolor(10);
input(s,8); N:=s;
n:='MENUS\'+n+'.MNU';
readin;
if exist=false then begin makenewfile; readin; end;
end;
procedure directives;
var s:astr; R:Char;
begin
repeat
writeln;
tc(12);
write('Current Directives:');
writeln;
tc(11);
write('1> ');
tc(3);
writeln('File Printed : ',directive);
tc(11);
write('2> ');
tc(3);
writeln('Menu Prompt : ',menuprompt);
writeln; tc(11);
write('Enter Selection [1-2] or Q to quit : ');
tc(10);
r:=readkey; r:=upcase(r); writeln(r);
if (r='1') then begin
tc(12); writeln('Enter file printed. DO NOT mark a extension if you want it to');
writeln('also print ANSI files to ansi users.'); writeln;
tc(11); write('File Printed : ');
tc(10); input(s,12); directive:=s;
end;
if r='2' then begin
tc(12); writeln('Enter new menu prompt. Use "^" for a command marker');
writeln('Use ^n where n is 0-9 for color, and cmd letters for');
writeln('strings.');
writeln;
tc(11); write('Menu Prompt : ');
tc(10);
inputl(s,50); menuprompt:=s;
end;
until (r='Q');
end;
procedure changedir;
var s:astr;
begin
writeln;
tc(11);
write('Enter new directory : ');
textcolor(10);
input(s,20);
chdir(s);
cmdline;
end;
procedure menu;
var r:char;
begin
repeat
tc(14);
writeln;
writeln;
write('W');tc(15);write('ork file ');tc(14);
write('A');tc(15);write('dd cmd to menu');
writeln;tc(14);
write('D');tc(15);write('isplay list ');tc(14);
write('Q');tc(15);write('uit to DOS'); tc(14);writeln;
write('S');tc(15);write('ave menu file ');tc(14);
write('*');tc(15);write('Change directory');tc(14);writeln;
write('T');tc(15);write('erminate cmd ');tc(14);
write('E');tc(15);write('dit a cmd'); writeln; tc(14);
write('X');tc(15);write('Command Directives.');
writeln;
writeln;
tc(10);
write('Cmd->');
r:=readkey;
r:=upcase(r); textcolor(13);
write(r);
if (r='A') or (r='T') or (r='E') then changed:=true;
if r='D' then display;
if r='A' then addcmd;
if r='W' then workfile;
if r='S' then savemenu;
if r='*' then changedir;
if r='T' then deletecmd;
if r='E' then editcmd;
IF R='X' THEN directives;
until (r='Q');
if changed then asksave;
end;
Procedure Menu_Edit;
var i:integer; r:char;
begin
clrscr;
changed:=false;
for i:=1 to 50 do begin
cmdl[i]:='';
msl[i]:=0;
cmdtype[i]:=0;
optdata[i]:=0;
optstr[i]:='';
end;
n:='MENUS\MAIN.MNU'; readin;
clrscr;
cmdline;
writeln;
tc(12);
write('Telegard BBS MenuEdit -- V 1.0 By Carl Mueller');
writeln;
menu;
end;
END.