home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Jason Aller Floppy Collection
/
341.img
/
TCS161S.ZIP
/
FILE2.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1989-09-23
|
10KB
|
405 lines
var ud:udrec;
curarea:integer;
offliney,vcr:boolean;
validprotos:set of char;
xtype:char;
procedure beepbeep (ok:integer);
begin
delay (500);
write (^B^M);
case ok of
0:write ('Xfer completed!');
1:write ('Xfer Aborted just before EOF!');
2:write ('Xfer Aborted!')
end;
writeln (^G^M)
end;
procedure seekafile (n:integer);
begin
seek (afile,n-1)
end;
function numareas:integer;
begin
numareas:=filesize (afile)
end;
procedure seekudfile (n:integer);
begin
seek (udfile,n-1)
end;
function numuds:integer;
begin
numuds:=filesize (udfile)
end;
procedure assignud;
begin
close (udfile);
assign (udfile,'AREA'+strr(curarea))
end;
function sponsoron:boolean;
begin
sponsoron:=match(area.sponsor,unam) or issysop
end;
function getapath:lstr;
begin
getapath:=area.xmodemdir;
getapath:=getpath (area.xmodemdir);
end;
function makearea:boolean;
var num,n:integer;
a:arearec;
begin
makearea:=false;
num:=numareas+1;
n:=numareas;
writestr ('Create Area '+strr(num)+' [y/n]? *');
if yes then begin
writestr ('Area Name: &');
if length(input)=0 then exit;
a.name:=input;
writestr ('Access Level:');
if length(input)=0 then exit;
a.level:=valu(input);
{writestr ('Group Access (y/n):');
if yes then a.usegroup:=true else a.usegroup:=false;
if a.usegroup then begin
writestr ('Group Filename:');
a.groupfn:=input;
end; }
writestr ('Sponsor [CR/'+unam+']:');
if length(input)=0 then input:=unam;
a.sponsor:=input;
{ writestr ('Entry Password [CR/None]:');
if length(input)=0 then a.areapw:='' else
a.areapw:=input; }
writestr ('Able to Upload into this area? [CR/Yes]:');
if (length(input)=0) or (upcase(input[1])='Y') then
a.upload:=true else a.upload:=false;
writestr ('Able to Download from this area? [CR/Yes]:');
if (length(input)=0) or (upcase(input[1])='Y') then
a.download:=true else a.download:=false;
a.xmodemdir:=getapath;
seekafile (num);
write (afile,a);
area:=a;
curarea:=num;
assignud;
rewrite (udfile);
writeln ('Area created');
makearea:=true;
writelog (15,4,a.name)
end
end;
procedure setarea (n:integer);
var t:text;
l:string;
procedure nosucharea;
begin
writeln (^B'Invalid File Area!')
end;
begin
curarea:=n;
if (n>numareas) or (n<1) then begin
nosucharea;
if issysop
then if makearea
then setarea (curarea)
else setarea (1)
else setarea (1);
exit
end;
seekafile (n);
read (afile,area);
{ if area.usegroup then begin
assign (t,area.groupfn);
reset (t);
repeat
readln (t,l);
write ('Please Wait...');
until (eof(t)) or (match(l,unam));
write ('Uh Huh.');
if (match(unam,l)) then setarea (curarea)
else nosucharea;
end else }
if (urec.udlevel<area.level) and (not issysop)
then if curarea=1
then error ('User can''t access first area','','')
else
begin
nosucharea;
setarea (1);
exit
end;
{ if length(area.areapw)>0 then begin
writeln;
writestr ('Entry Password:');
if length(input)=0 then exit;
if not match(input,area.areapw) then exit;
end; }
assignud;
close (t);
close (udfile);
reset (udfile);
if ioresult<>0 then rewrite (udfile);
writeln (^B^M'Area: '^S,area.name,^R' ['^S,curarea,^R']');
if sponsoron then writeln (^R'['^S'%'^R']:Xfer Sponsor Commands');
writeln
end;
procedure spacelen(le:byte);
var aaa:byte;
begin
for aaa:=1 to le do
write(' ');
end;
procedure linelen(le:byte);
var aaa:byte;
begin
for aaa:=1 to le do
write('─');
end;
Procedure toplinearea;
begin
writeln (^R'┌───┬───────────────────────────────────────┬───────┬─────┬──────┐');
writeln (^R'│ '^U'#'^R' │ '^U'Area Name'^R' │ '^U'Level'^R' │ '^U'UPL'^R' │ '^U'DOWN'^R' │');
writeln (^R'├───┼───────────────────────────────────────┼───────┼─────┼──────┤');
end;
Procedure bottomlinearea;
begin
writeln (^R'└───┴───────────────────────────────────────┴───────┴─────┴──────┘');
end;
Procedure topfileline;
begin;
writeln (^R'┌───┬──────────────┬────────┬───────────┬─────────────────────────────────────┐');
writeln (^R'│ '^U'# '^R'│ '^U'Filename '^R'│'^U' Points '^R'│'^U' Size '^R'│'^U' Description'^R+
' │');
writeln (^R'├───┼──────────────┼────────┼───────────┼─────────────────────────────────────┤');
end;
Procedure bottomfileline;
begin
writeln (^R'└───┴──────────────┴────────┴───────────┴─────────────────────────────────────┘');
end;
procedure listareas;
var a:arearec;
cnt:integer;
begin
if exist (textfiledir+'Filearea.BBS') then
printfile (textfiledir+'Filearea.BBS') else
begin
writehdr ('File Area List');
seekafile (1);
toplinearea;
for cnt:=1 to numareas do begin
read (afile,a);
if a.level<=urec.udlevel
then begin
write (^R'│'^U,cnt);
spacelen(3-length(strr(cnt)));
write (^R'│ '^U,a.name,^R);
spacelen(38-length(a.name));
write (^R'│'^U,a.level,^R);
spacelen(7-length(strr(a.level)));
if a.upload then
write(^R'│ '^U'YES ')
else
write(^R'│ '^U'NO ');
if a.download then
writeLn(^R'│ '^U'YES'^R' │')
else
writeLn(^R'│ '^U'NO'^R' │');
end;
if break then exit
end;
end;
bottomlinearea;
end;
function getareanum:integer;
var areastr:sstr;
areanum:integer;
begin
getareanum:=0;
if length(input)>1
then areastr:=copy(input,2,255)
else begin
listareas;
repeat
writestr (^M'Area Number [?/List]:');
if input='?' then listareas else areastr:=input
until (input<>'?') or hungupon;
end;
if length(areastr)=0 then exit;
areanum:=valu(areastr);
if (areanum>0) and (areanum<=numareas)
then getareanum:=areanum
else begin
writestr ('No such area!');
if issysop then if makearea then getareanum:=numareas
end
end;
procedure getarea;
var areanum:integer;
begin
areanum:=getareanum;
if areanum<>0 then setarea (areanum)
end;
function getfname (path:lstr; name:mstr):lstr;
var l:lstr;
begin
l:=path;
if length(l)<>0
then if not (l[length(l)] in [':','\'])
then l:=l+'\';
l:=l+name;
getfname:=l
end;
procedure listfile (n:integer; extended:boolean);
var ud :udrec;
q :sstr;
a :string;
b :string;
c :string;
ed :string;
desc :string;
lamedata :string[1];
up1 :byte;
dah :boolean;
begin
seekudfile (n);
read (udfile,ud);
write (^R'│'^S+strr(n)+^R);
spacelen(3-length(strr(n)));
write (^R'│');
write(^S+' ',UPSTRING(ud.filename));
spacelen(13-length(ud.filename));
write (^R'│'^S);
desc:=ud.descrip;
dah:=false;
if ud.newfile
then write (^U'['^S'New'^U'] ')
else if ud.specialfile
then write (^U'['^S'Ask'^U'] ')
else if ud.points>0
then tab (strr(ud.points),8)
else write (^U'['^S'Free'^U'] ');
write (^R'│');
if exist (getfname(ud.path,ud.filename)) then begin
write(^S,strlong(ud.filesize));
spacelen(11-length(strlong(ud.filesize)));
write (^R'│');
end;
if not exist (getfname(ud.path,ud.filename)) then begin
write (^U'['^S'Offline'^U']'^R' │');
end;
if length(ud.descrip)<=2 then begin
write (^U'['^S' No Description '^U']');
spacelen(19);
writeLn(^R'│');
end;
if length(ud.descrip)>38 then begin
repeat
up1:=37;
repeat
dec(up1);
lamedata:=copy(desc,up1,1);
if (lamedata=' ') and (dah=true) and (length(desc)>38) then begin
inc(cn);
write (^R'│ │ │ │ │');
write(^S+copy(desc,1,up1));
spacelen(37-length(copy(desc,1,up1)));
writeln(^R'│');
delete(desc,1,up1);
end;
if (lamedata=' ') and (dah=false) then begin
inc(cn);
write(^s,copy(desc,1,up1));
spacelen(37-length(copy(desc,1,up1)));
writeln(^R,'│');
delete(desc,1,up1);
dah:=true
end;
until (lamedata=' ')
until (length(desc)<=37);
end;
if length(ud.descrip)>38 then begin
write (^R'│ │ │ │ │');
end;
if length(desc)>2 then begin
write(^S+desc);
spacelen(37-length(desc));
writeln(^R'│');
if cn>18 then cn:=18
end;
end;
function nofiles:boolean;
begin
if numuds=0 then begin
nofiles:=true;
writestr (^M'Sorry, no files!')
end else nofiles:=false
end;
Function capfir(inString:STRING):STRING;
begin
capfir:=upcase(inString[1]);
end;
procedure listfiles (extended:boolean);
var cnt,max,r1,r2:integer;
non:boolean;
begin
if nofiles then exit;
clearscr;
cn:=0;
non:=false;
max:=numuds;
thereare (max,'File','Files');
parserange (max,r1,r2);
if r1=0 then exit;
writeln;
topfileline;
for cnt:=r1 to r2 do begin
inc(cn);
if (cn>=18) and (non=false) then
begin
bottomfileline;
cn:=0;
writestr(^P'File Listings Comamnds ['^S'Q/'^R'Quit'^P']['^S'N/'^R'Non-stop'^P']['^S'CR/'^R'Continue'^P']: *');
if capfir(input)='Q' then exit;
if capfir(input)='N' then non:=true;
topfileline;
end;
listfile (cnt,extended);
if break then exit
end;
bottomfileline;
end;