home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 5
/
FreshFish_July-August1994.bin
/
bbs
/
comm
/
bbbbs-7.2.lha
/
BBBBS
/
BBBBS72.lha
/
rexx
/
bbsMail.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1994-04-09
|
31KB
|
1,154 lines
/* $VER: bbsMail.rexx 7.2 (9.4.94) Copyright © 1994 Richard Lee Stockton
* BBBBS mail reader/sender with optional file attach
* FREELY DISTRIBUTABLE
* Thanks to Matt English for "SendFile.rexx"
* Thanks to John Ruckart for additional "detail work".
*/
IF ~SHOW('P','QuickSortPort') THEN CALL setup.rexx()
IF ~SHOW('P','QuickSortPort') THEN EXIT 666
title.=''
title.1='bbsMail for BBBBS'
title.2='Version 7.2'
title.3='30-Mar-94'
def=''
pen1='
'
pen2='
'
pen3='
'
lineup='1B'x'M'
changed=0
linesperpage=20
namemask=COMPRESS(XRANGE(),XRANGE('A','Z')' _-')
topath='RAM:'
figarg='s:CONFIG.BBS'
IF ~EXISTS(figarg) THEN figarg='BBS:BBS_TEXT/CONFIG.BBS'
x=OPEN(f,figarg,'R')
IF x=0 THEN
DO
SAY 's:CONFIG.BBS and BBS:BBS/CONFIG.BBS are both missing!'
EXIT
END
lynes.=''
DO i=1 TO 40
lynes.i=READLN(f)
END
CALL CLOSE(f)
compos=POS('/*',lynes.1)
IF compos>0 THEN lynes.1=LEFT(lynes.1,compos-1)
bbsname=STRIP(lynes.1)
sysop=WORD(lynes.2,1)
compos=POS('/*',lynes.3)
IF compos>0 THEN lynes.3=LEFT(lynes.3,compos-1)
bbsdevice=word(lynes.4,1)
sysoplevel=WORD(lynes.5,1)
bbspath=WORD(lynes.6,1)
IF ~EXISTS(bbspath) THEN
DO
SAY bbspath 'does not exist!'
EXIT
END
testchar=RIGHT(bbspath,1)
IF testchar~='/' & testchar~=':' THEN bbspath=bbspath'/'
msgpath=WORD(lynes.7,1)
IF ~EXISTS(msgpath) THEN
DO
SAY msgpath 'does not exist!'
EXIT
END
testchar=RIGHT(msgpath,1)
IF testchar~='/' & testchar~=':' THEN msgpath=msgpath'/'
msgpath=msgpath'MSG'
IF WORD(lynes.25,1)=1 THEN scratch=bbspath'Scratch'
ELSE scratch='RAM:Scratch'
CALL MAKEDIR(scratch)
OPTIONS PROMPT ' Are you 'sysop'? (Yn) > '
PULL answer
IF answer='N' THEN
DO
SAY
OPTIONS PROMPT ' Please enter your name > '
PULL name
name=cleanstring(name)
IF name='' THEN EXIT
IF ~EXISTS(bbspath'Users/'name) THEN
DO
SAY name 'does not exist!'
EXIT
END
END
ELSE name=sysop
userfile=bbspath'Users/'name
CALL OPEN(f,userfile,'R')
data.=''
DO i=1
line=READLN(f)
IF EOF(f) THEN LEAVE i
data.i=line
END
CALL CLOSE(f)
data.0=i-1
city=docity(data.3)
password=data.5
level=data.20
passprompt=pen3' Please Enter Password:
'
DO tries=1 TO 3
OPTIONS PROMPT passprompt
PULL newpassword
SAY def
IF(password=newpassword) THEN LEAVE tries; /* correct password */
IF tries=3 THEN
DO
SAY
SAY 'Access terminated.'
SAY '*** Bad password ***' newpassword '***'
EXIT
END
passprompt='Incorrect. Password: ' /* ask again */
END
Friends.=''
IF readopen(bbspath'Friends/'name) THEN
DO
DO i=1
Friends.i=READLN(f)
IF EOF(f) THEN LEAVE i
END
Friends.0=i-1
CALL CLOSE(f)
END
SAY
SAY' OK, 'name' here we go....'
SAY
IF level>sysoplevel THEN
DO
CALL showtext(bbspath'Email/'sysop'/NEW_FILES')
CALL showtext(bbspath'Lists/NEW_USERS')
CALL showtext(bbspath'Lists/CBV_USERS')
END
DO FOREVER
replysubj=''
thechosen.=''
SAY
DO i=1 TO 3
SAY CENTER(title.i,74)
END
SAY
CALL readmail()
IF temp='Q' THEN CALL seeya
END
/* SUBROUTINES */
readmail:
line='Find Email ['pen3'T'def']o You or ['pen3'W'def']rite New Email (Twq) > 'def
temp=getinput(1 1 line)
IF temp='W' THEN
DO
CALL editor()
RETURN
END
ELSE IF temp='Q' THEN CALL seeya
SAY 'Checking your mailbox..'
nomail=1
CALL MAKEDIR(bbspath'EMail/'name)
mailist=sortnumbers(SHOWDIR(bbspath'Email/'name))
IF WORDS(mailist)=0 THEN
DO
SAY lineup'Your mailbox is empty. '
SAY
RETURN
END
line=WORDS(mailist)
IF line>1 THEN line=line 'letters'
ELSE line=line 'letter'
line=line 'waiting.'
SAY line
DO ii=1 TO WORDS(mailist)
SAY 'Email:' pen3||WORD(mailist,ii)||def
END
onename=''
IF WORDS(mailist)>3 THEN
DO
IF getinput(1 1 'Read all private mail? (nY) > ')='N' THEN
DO
onename=getinput(1 0 'Read ONLY private mail from? > ')
onename=SPACE(STRIP(UPPER(onename)),1,'_')
onename=COMPRESS(onename,'.,:/*#?^ ')
IF onename='' THEN RETURN
IF ~EXISTS(bbspath'Users/'onename) & picklist.1~='BBBBS' THEN
DO
SAY '***'pen3 onename def'does not exist!'
RETURN
END
END
END
DO letter=1 TO WORDS(mailist)
readname=WORD(mailist,letter)
uname=readname
caret=LASTPOS('.',uname)
IF caret>2 THEN uname=LEFT(uname,caret-1)
IF onename~='' & onename~=uname THEN ITERATE letter
arg=bbspath'Email/'name'/'readname
CALL readlines(arg 1)
delnum=WORD(lynes.1,2)
CALL seelines(1)
nomail=0
nonstop=0
mailfile=''
IF UPPER(WORD(lynes.1,3))='FILE:' THEN mailfile=WORD(lynes.1,4)
ELSE IF UPPER(WORD(lynes.2,3))='FILE:' THEN mailfile=WORD(lynes.2,4)
IF mailfile~='' & readname~='NEW_FILES' & readname~='FILELISTS_REPORT' & readname~='INACTIVE_USERS' & LEFT(readname,3)~='MSG' THEN
DO
IF LEFT(RIGHT(mailfile,4),1)~='.' & LEFT(readname,6)='BBBBS.' THEN
DO
SAY
SAY pen3'The attached file is unarchived and may be incomplete.'
SAY 'If the archiver is still building this file, downloading will fail.'def
IF getinput(1 1 'Do you want to try to download it anyway? (Ny) > ')~='Y' THEN ITERATE letter
SAY
END
curdir=PRAGMA('D')
CALL setdir(bbspath'EmailFiles/'name)
ADDRESS COMMAND 'C:List >*' mailfile 'DATES'
SAY ' Attached file:' pen3||mailfile||def
junk=getinput(1 1 'Leave file in your EmailFiles? (Ny) > ')
IF junk='Y' THEN mailfile=''
ELSE
DO
junk=getinput(1 1 'Deleting Mail will also delete file. Copy somewhere now? (Ny) > ')
IF junk='Y' THEN
DO
tofile=GetFile(150,36,topath,mailfile,' Select Destination Name ')
ADDRESS COMMAND 'C:Copy' PRAGMA('D')'/'mailfile tofile
END
END
END
IF readname~='NEW_FILES' & readname~='FILELISTS_REPORT' & readname~='INACTIVE_USERS' & LEFT(readname,3)~='MSG' & LEFT(readname,6)~='BBBBS.' THEN
DO
tempchar='A'
DO WHILE tempchar='A'
tempchar=getinput(1 1 '['pen3'A'def']gain ['pen3'C'def']ontinue ['pen3'R'def']eply? (acR) > ')
IF tempchar='' THEN tempchar='R'
IF tempchar='A' THEN CALL seelines(1)
END
IF tempchar='R' THEN
DO
IF WORDS(lynes.4)<2 THEN replysubj='?'
ELSE replysubj=SUBSTR(lynes.4,WORDINDEX(lynes.4,2))
CALL editor(uname)
replysubj=''
END
END
IF LEFT(readname,6)~='BBBBS.' THEN
DO
tempchar='A'
DO WHILE tempchar='A'
tempchar=getinput(1 1 'Forward mail from'pen3 uname def'to other users? (aNy) > ')
IF tempchar='A' THEN CALL seelines(1)
END
IF tempchar='Y' THEN
DO
IF selectchosen(1 pen3'Forward Email To: 'def)=0 THEN
DO ei=1 TO thechosen.0 WHILE thechosen.ei~=''
CALL MAKEDIR(bbspath'EMail/'thechosen.ei)
forwardarg=bbspath'Email/'thechosen.ei'/'readname
ADDRESS COMMAND 'C:COPY' bbspath'Email/'name'/'readname forwardarg
CALL readlines(forwardarg 1)
lynes.1=lynes.1' Forwarded to you by' name TIME('C') DATE()
CALL DELETE(forwardarg)
CALL savelines(forwardarg)
IF WORDS(lynes.2)>3 THEN
DO
forname=bbspath'EmailFiles/'name'/'WORD(lynes.2,4)
IF EXISTS(forname) THEN
DO
CALL MAKEDIR(bbspath'EmailFiles/'thechosen.ei)
ADDRESS COMMAND 'C:COPY' forname bbspath'EmailFiles/'thechosen.ei
END
END
line='Mail' pen3||readname||def 'forwarded to' pen3||thechosen.ei||def
IF emailonline>=0 THEN emailonline=emailonline+1
SAY line
END
END
END
tempchar=''
tempstr='Delete the mail ('pen3||delnum||def') from'pen3 uname def'that you just read?'
IF mailfile='' THEN tempchar=getinput(1 1 tempstr '(nqY) > ')
ELSE
DO WHILE tempchar~='N' & tempchar~='Q' & tempchar~='Y'
tempchar=getinput(1 1 tempstr '(nqy) > ')
END
IF tempchar='Q' THEN
DO
IF getinput(1 1 'Quit reading your Email