home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
BEEHIVE
/
BBS
/
ROVER12A.ARC
/
IMPORT.INC
< prev
next >
Wrap
Text File
|
1991-08-11
|
5KB
|
229 lines
{** IMPORT.INC **}
procedure import_menu;
var
ch: char;
begin
folder:= 0;
deleted:= 0;
public:= 0;
writeln('IMPORT MENU:');
writeln('(control C aborts)');
writeln;
write('Select folder number ([1]-9): ');
ch:= readKeyETX;
if ch in ['1'..'9'] then folder:= ord(ch) - $30
else folder:= 1;
writeln;
write('Select [P]ublic or p<R>ivate: ');
case upcase(readKeyETX) of
'P': public:= 0;
'R': public:= 1;
else public:= 0;
end;
writeln;
writeln;
end; {import_menu}
procedure addline(buf: bufftype);
var
I: byte;
msglin: msgtype;
begin
for I:= 1 to 64 do
msglin[I]:= buf[I];
wrtmsg(msglin, nextrecord);
nextrecord:= nextrecord + 1;
for I:= 1 to 64 do
msglin[I]:= buf[I + 64];
wrtmsg(msglin, nextrecord);
nextrecord:= nextrecord + 1;
msgindex.num_of_recs:= msgindex.num_of_recs + 2;
end; {addline}
procedure addstring(st: str64);
var
I, L: byte;
msglin: msgtype;
begin
L:= length(st);
if L> 0 then
for I:= 1 to L do
msglin[I]:= ord(st[I]);
if L< 64 then
msglin[L+1]:= $0D;
msglin[L+2]:= 0;
for I:= L+3 {1} to 64 do
msglin[I]:= 1; {0;}
wrtmsg(msglin, nextrecord);
nextrecord:= nextrecord + 1;
msgindex.num_of_recs:= msgindex.num_of_recs + 1;
end; {addstring}
procedure form_header;
var
I: byte;
st, st1: str16;
msglin: msgtype;
begin
st:= fillstr16(SOH);
sender:= allcaps(sender);
sender1:= copy(sender, 11, 29);
receiver:= allcaps(receiver);
receiver1:= copy(receiver, 17, 29);
line1[1]:= 'Left ' + time + ', ';
line1[2]:= date + '.' + CR + 'For ';
line1[3]:= receiver + st;
st1:= receiver1 + st;
st1[15]:= CR;
line1[4]:= st1;
line1[5]:= 'From ' + sender;
line1[6]:= sender1 + st;
st1:= st;
st1[5]:= CR;
st1[6]:= CR;
line1[7]:= st1;
line1[8]:= st;
msgindex.num_of_recs:= 0;
transfertobuffer;
addline(filebuffer);
end; {form_header}
procedure get_body;
var
len, spr: byte;
begin
while not EOF(snapfil) do
begin
readln(snapfil, line);
if (length(line) = 0) then line:= CR;
line:= ' ' + line;
linebuffer:= '';
len:= length(line);
spr:= length(sparebuffer);
if (spr = 0) then
begin
if (len = 64) then linebuffer:= line;
if (len > 64) then
begin
linebuffer:= line;
sparebuffer:= copy(line, 65, 20);
end;
if (len < 64 ) then sparebuffer:= line;
end
else {sparebuffer > 0}
begin
linebuffer:= sparebuffer + line;
if ((len + spr) = 64) then
sparebuffer:= '';
if ((len + spr) < 64) then
begin
linebuffer:= '';
sparebuffer:= sparebuffer + line;
end;
if ((len + spr) > 64) then
sparebuffer:= copy(line, 64 - spr +1, 90);
end;
if (length(linebuffer) > 0) then addstring(linebuffer);
if (length(sparebuffer) > 64) then
begin
linebuffer:= sparebuffer;
sparebuffer:= copy(sparebuffer, 65, 90);
addstring(linebuffer);
end;
end;
end; {get_body}
procedure writemessage;
begin
form_header;
get_body;
end; {writemessage}
function readsnapfile: boolean;
var
test: boolean;
begin
count:= 1;
{
time:= '04:58:54';
date:= '08/19/88';
sender:= 'Roy Prickett';
receiver:= 'Phil Hansford';
}
snapfilename:= 'TEST';
test:= opensnapfile(K);
if test then
begin
while (count < 5) and not EOF(snapfil) do
begin
readln(snapfil, line);
case count of
1: if (pos('Date: ', line) = 1) then
begin
date:= copy(line, 7, 8);
time:= copy(line, 16, 8);
end else write(^G);
2: if (pos('From: ', line) = 1 ) then
sender:= copy(line, 7, 40);
3: if (pos('To: ', line) = 1) then
receiver:= copy(line, 7, 40);
4: if (pos('SEE ALSO', line) =1) or (pos('REPLY TO', line) = 1)
then count:= count -1
else if (pos('Subj: ', line) = 1) then
subject:= copy(line, 7, 40);
end; {case}
{
============================
Date: 06/23/88 19:24:20
From: Craig Derouen
To: All (on 1068/1)
SEE ALSO #3
Subj: Welcome!
===============================
}
count:= count + 1;
end;
count:= 1;
k:= k + 1;
sparebuffer:= '';
end;
readsnapfile:= test;
end; {readsnapfile}
procedure do_import;
var
st: str64;
begin
if not import then exit;
writeln('IMPORT FILES:');
writeln;
writeln('working...');
writeln;
{index previously read}
msgindexrec:= index.last_msgindex_rec;
if not readmsgindex then finis(2);
msgindex.public:= public; {set from menu}
msgindex.folder:= folder;
k:= 1; {snapfile number}
while readsnapfile do
begin
writemessage;
if (length(sparebuffer) > 0) then
begin
st:= sparebuffer;
addstring(st);
end;
update_msgindexrec;
writemsgindex;
update_indexrec;
end;
saveindex;
end; {do_import}