home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Fish 2
/
goldfish_vol2_cd1.bin
/
files
/
comm
/
bbs
/
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? (Ny) > ')='Y' THEN
DO
readname=''
uname=''
RETURN
END
END
ELSE IF tempchar~='N' THEN
DO
dirname=bbspath'Email/'name'/'
nodelete=0
IF name~=sysop & uname~=sysop & WORD(lynes.2,2)~='BBBBS' & WORD(lynes.2,2)~=sysop & WORD(lynes.3,2)~=sysop THEN
nodelete=1
IF nodelete THEN
ADDRESS COMMAND 'C:Copy' dirname||readname bbspath'Email/'sysop
CALL DELETE(dirname||readname)
tempstr='Old email'
IF mailfile~='' & readname~='NEW_FILES' & readname~='FILELISTS_REPORT' & readname~='INACTIVE_USERS' & EXISTS(bbspath'EmailFiles/'name'/'mailfile) THEN
DO
IF nodelete THEN
ADDRESS COMMAND 'C:Copy' bbspath'EmailFiles/'name'/'mailfile bbspath'EmailFiles/'sysop
CALL DELETE(bbspath'EmailFiles/'name'/'mailfile)
CALL DELETE(bbspath'EmailFiles/'name'/'mailfile'.xdl')
tempstr=tempstr 'and attached file'
END
tempstr=tempstr 'deleted. Thank you for keeping a clean BBS!'
SAY tempstr
IF tempchar='Q' THEN
IF getinput(1 1 'Quit reading your Email? (Ny) > ')='Y' THEN
DO
readname=''
uname=''
RETURN
END
END
ELSE IF LEFT(readname,3)='MSG' & level>sysoplevel THEN
DO
ii=LEFT(readname,POS('.',readname)-1)
ii=SUBSTR(ii,4)%1
IF getinput(1 1 'Move this message back to the' msg.ii 'conference? (nY) > 'def)~='N' THEN
DO
temp=TRANSLATE(readname,'/','.')
temp=SUBSTR(temp,4)
lynes.1='!!'STRIP(lynes.1)
CALL savelines(msgpath||temp)
CALL DELETE(bbspath'Email/'name'/'readname)
END
END
ELSE IF LEFT(readname,3)~='MSG' & readname~='NEW_FILES' & readname~='FILELISTS_REPORT' & readname~='INACTIVE_USERS' THEN
DO
arg=bbspath'Email/'name'/'readname
CALL readlines(arg 1)
IF WORDS(lynes.5)<7 THEN
DO
lynes.5=lynes.5' (Rcvd)' DATE('W') DATE() TIME('C')
CALL DELETE(arg)
CALL savelines(arg)
SAY 'Email has been marked as received.'
END
END
readname=''
uname=''
arg=''
END
IF nomail THEN SAY 'No mail was found.'
thechosen.=''
RETURN
sortnumbers: PROCEDURE
PARSE ARG slist
IF STRIP(slist)='' THEN RETURN ''
sorted.=''
oldest=999999
newest=0
newlist=''
DO si=1 TO WORDS(slist)
testword=WORD(slist,si)
IF ~DATATYPE(testword,'W') THEN
DO
testpos=LASTPOS('.',testword)
IF testpos>0 THEN tempnum=SUBSTR(testword,testpos+1)
ELSE
DO
newlist=testword newlist
ITERATE si
END
END
ELSE tempnum=testword/1
IF sorted.tempnum='' THEN
DO
sorted.tempnum=testword
sorted.tempnum.0=1
IF DATATYPE(tempnum,'W') THEN
DO
IF tempnum>newest THEN newest=tempnum
IF tempnum<oldest THEN oldest=tempnum
END
END
ELSE newlist=newlist testword
END
IF oldest~=999999 & newest~=0 THEN
DO si=oldest TO newest
IF sorted.si.0=1 THEN newlist=newlist sorted.si
END
DROP sorted. oldest newest
RETURN STRIP(newlist)
editor:
ARG toname .
msgnum=0
thechosen.=''
lastwrit=countcheck(bbspath'Numbers/LastMail 0')
IF toname~='' THEN
DO
toname=check_alias(toname)
thechosen.1=toname
thechosen.0=1
END
ELSE IF selectchosen(1 pen3'Send PRIVATE EMail number' lastwrit+1 'To:'def)=1 THEN
DO
IF ~changed THEN RETURN
x=OPEN(f,bbspath'Users/'name,'W')
IF x=0 THEN
DO
SAY 'Unable to open' bbspath'Users/'name'!'
RETURN
END
SAY 'Updating your user data...'
IF data.0<27 THEN data.0=27
DO i=1 TO data.0
CALL WRITELN(f,data.i)
END
CALL CLOSE(f)
EXIT
END
toname=thechosen.1
toname=cleanstring(toname)
IF toname='' THEN EXIT
CALL MAKEDIR(bbspath'EMail/'toname)
mailname=bbspath'EMail/'toname'/'name'.'lastwrit+1
lynes.=''
lynes.0=6
lynes.1=' Mail:' lastwrit+1
lynes.2=' From:' name
IF city~='' THEN lynes.2=lynes.2' - 'city
lynes.3=' To:' toname
IF readopen(bbspath||'Users/'toname) THEN
DO
CALL READLN(f)
CALL READLN(f)
temp=READLN(f)
CALL CLOSE(f)
temp=docity(temp)
IF temp~='' THEN lynes.3=lynes.3' - 'temp
END
IF replysubj='' THEN
DO
subj=''
SAY pen3'Enter the'def 'Subject' pen3'of this message (1 line).'def
subj=getinput(0 0 pen3': 'def)
END
ELSE subj=replysubj
IF LENGTH(subj)>66 THEN subj=LEFT(subj,66)
IF subj='' THEN subj='?'
lynes.4=' Subj:' subj
lynes.5=' Date:' DATE('W') DATE()' 'TIME('C')
lynes.6=LEFT('',74,'=')
DO i=1 TO lynes.0
SAY lynes.i
END
CALL writebuffer(scratch'/MessageLOCAL')
IF savelines(mailname) THEN RETURN 0
CALL seelines()
IF thechosen.0='' THEN
DO
thechosen.0=1
thechosen.1=toname
END
carbons=thechosen.0+1
DO FOREVER
IF thechosen.0>1 THEN
DO
SAY 'Copies To:'
junk=''
DO i=2 TO thechosen.0
junk=junk thechosen.i
END
SAY junk
END
pline='['pen3'C'def']opies'
pline=STRIP(pline '['pen3'E'def']dit ['pen3'K'def']ill ['pen3'R'def']ead')
pline=pline '['pen3'U'def']pload-Text ['pen3'S'def']end EMail? (ekrSu) 'def
junk=getinput(1 1 pline)
IF junk='E' THEN
DO
IF level>sysoplevel THEN firstedit=1
ELSE firstedit=7
IF bbsED(firstedit mailname)=2 THEN RETURN 0
junk='R'
END
ELSE IF junk='C' THEN
DO
CALL selectchosen(carbons pen3'Carbon Copies To: 'def)
junk='R'
END
ELSE IF junk='K' THEN
DO
IF DELETE(mailname)=1 THEN
DO
SAY 'EMail DELETED.'
IF WORD(lynes.1,4)~='' THEN
IF DELETE(bbspath'EMailFiles/'toname'/'WORD(lynes.1,4))=1 THEN
SAY 'Attached file deleted.'
END
RETURN 0
END
ELSE IF junk='U' THEN
DO
SAY 'Ready to append' pen3'TEXT ONLY'def
pline='Are you SURE your file is un-compressed text? (Ny) > '
IF getinput(1 1 pline)='Y' THEN
DO
frompath=GETCLIP('BBS_frompath')
IF frompath='' THEN frompath='RAM:'
farg=GetFile(150,36,frompath,'',' Select TextFile to Append ')
IF farg~='' & EXISTS(farg) THEN
DO
CALL readlines(farg lynes.0+1)
CALL SETCLIP('BBS_frompath',WORD(lastslash(farg),2))
CALL savelines(mailname)
END
END
junk='R'
END
IF junk='R' THEN
DO
CALL readlines(mailname 1)
CALL seelines()
nonstop=0
END
ELSE BREAK
END
IF replysubj~='' & readname~='' & LEFT(readname,5)~='BBBBS' & uname~='' & uname~='UNAME' THEN
DO
junk=getinput(1 1 'Attach original mail from' uname'? (nY) > ')
IF junk~='N' THEN
DO
arg=bbspath'Email/'name'/'readname
n=lynes.0+1
IF ~readlines(arg n) THEN
DO
lynes.n=LEFT('',75,'^')
CALL savelines(mailname)
END
END
END
junk=getinput(1 1 pen3'Attach a file to this message? (Ny) > 'def)
IF junk='Y' THEN
DO subloop1=1 TO 1
CALL MAKEDIR(bbspath'EmailFiles/'toname)
CALL setdir(bbspath'EmailFiles/'toname)
frompath=GETCLIP('BBS_frompath')
IF frompath='' THEN frompath='RAM:'
fdir=''
DO subloop2=1
fromfile=GetFile(150,36,frompath,'',' Select File to Upload ')
IF fromfile='' THEN LEAVE subloop1
IF EXISTS(fromfile) THEN LEAVE subloop2
SAY
SAY fromfile 'does not exist!'
END
x=LASTPOS('/',fromfile)
IF x=0 THEN x=POS(':',fromfile)
IF x>0 THEN
DO
arg=SUBSTR(fromfile,x+1)
fdir=LEFT(fromfile,x)
IF RIGHT(fdir,1)='/' THEN fdir=LEFT(fdir,x-1)
CALL SETCLIP('BBS_frompath',fdir)
END
ELSE arg=fromfile
ADDRESS COMMAND 'C:COPY' fromfile bbspath'EMailFiles/'toname'/'arg
IF RC=0 THEN
DO
IF WORD(STATEF(bbspath'EmailFiles/'toname'/'arg),2)>1 THEN
DO
CALL readlines(mailname 1)
IF arg~='' THEN lynes.1=lynes.1' FILE: 'arg
CALL setdir(curdir)
CALL DELETE(mailname)
CALL savelines(mailname)
END
END
ELSE
DO
CALL DELETE(bbspath'EmailFiles/'toname'/'arg)
SAY pen3'*** Upload failed! ***'def
END
END
totmail=WORD(data.17,2)
IF ~DATATYPE(totmail,'W') THEN totmail=thechosen.0
ELSE totmail=totmail+thechosen.0
data.17=WORD(data.17,1)' 'totmail' 'WORD(data.17,3)
changed=1
CALL readlines(mailname 1)
DO ui=1 TO thechosen.0
IF thechosen.ui='' THEN ITERATE ui
IF ui>1 THEN
DO
CALL MAKEDIR(bbspath'Email/'thechosen.ui)
newname=bbspath'Email/'thechosen.ui'/'name'.'lastwrit+1
IF ui<carbons THEN lynes.3=' To:' thechosen.ui
ELSE
DO
lynes.1=lynes.1' (Carbon Copy)'
lynes.3=' To:' thechosen.1
END
CALL savelines(newname)
IF WORDS(lynes.1)>3 & EXISTS(bbspath'EmailFiles/'thechosen.1'/'WORD(lynes.1,4)) THEN
DO
CALL MAKEDIR(bbspath'EmailFiles/'thechosen.ui)
ADDRESS COMMAND 'C:COPY' bbspath'EmailFiles/'thechosen.1'/'WORD(lynes.1,4) bbspath'EmailFiles/'thechosen.ui
line2='Copied' WORD(lynes.1,4)
SAY line2 'to the' thechosen.ui 'file area.'
END
END
IF GETCLIP('BBS_level')~='' & WORD(GETCLIP('BBS_lastcaller'),1)=thechosen.ui THEN
DO
oldmess=GETCLIP('BBS_MESSAGE')
IF oldmess~='' THEN oldmess=oldmess||'0D0A'x
CALL SETCLIP('BBS_MESSAGE',oldmess||'You have new Email')
END
SAY 'Mail Sent To' thechosen.ui
END
CALL countcheck(bbspath'Numbers/LastMail' lastwrit+1)
thechosen.=''
RETURN 1
bbsED:
PARSE ARG firstedit editarg .
notchanged=1
IF readlines(editarg 1) THEN RETURN 1
finfo=STATEF(editarg)
IF WORDS(finfo)>7 THEN finfo=SUBSTR(finfo,WORDINDEX(finfo,8))
ELSE finfo=''
SAY
SAY ' 'pen3'Entering the EDITOR module..'def
SAY
count=1
DO edloop=1
IF edcom='S' & SHOW('P','SPELL') THEN /* spell check */
DO
SAY pen3'You must use ['def'R'pen3']eplace to make corrections. 'pen2'Spellchecking...'def
CALL DELETE(scratch'/SpellLOCAL')
CALL savelines(scratch'/SpellLOCAL')
curdir=PRAGMA('D')
CALL setdir(spellpath)
CALL SpellChk.rexx(scratch'/SpellLOCAL')
CALL setdir(curdir)
END
ELSE
DO
IF edcom='R' | edcom='I' | edcom='L' THEN CALL wrapbuf(7)
IF edcom~='L' THEN count=count-linesperpage
IF count>=lynes.0 | count<1 THEN count=1
startcount=count
DO i=startcount TO lynes.0+1
IF ((i+1-startcount)//linesperpage)=0 THEN
DO
pline=' ['pen3'E'def']dit'
pline=pline ' ['pen3'RETURN'def']=Continue '
edcom=getinput(1 1 pline)
IF edcom~='' THEN LEAVE i
END
SAY pen3||RIGHT(i,2)||def lynes.i
count=count+1
END
END
SAY lineup' ['pen3'A'def']ppend ['pen3'C'def']ut ['pen3'I'def']nsert ['pen3'K'def']ill ['pen3'?'def'] Help'
pline=' ['pen3'L'def']ist ['pen3'P'def']aste ['pen3'R'def']eplace'
IF SHOW('P','SPELL') THEN pline=pline '['pen3'S'def']pellcheck'
pline=pline '['pen3'U'def']pload-Text > '
edcom=getinput(1 0 pline)
IF edcom='Q' | edcom='X' THEN edcom=''
IF edcom='?' THEN
DO
SAY
SAY ' Editor Help'
SAY '----------------------------------------------------------'
SAY ' an empty RETURN tells the editor you are done editing.'
SAY ' 7 edits line number 7, if it exists.'
SAY ' a Append text to this file.'
SAY ' c Cut selected line(s) of text to buffer.'
SAY ' i Insert blank line.'
SAY ' k Kill (delete) this file.'
SAY ' l List this file from selected line.'
SAY ' p Paste buffer contents to selected line number.'
SAY ' r Replace a phrase or line of text.'
SAY ' s Spellcheck this file.'
SAY ' u Upload a textfile to append to this file.'
SAY '----------------------------------------------------------'
SAY
OPTIONS PROMPT ''
PULL
END
IF edcom='K' THEN
DO
junk=getinput(1 1 'Are you' pen3'sure'def 'you want to delete' editarg'? (Ny) > ')
IF junk='Y' THEN
DO
IF DELETE(editarg)=1 THEN SAY editarg 'DELETED.'
IF WORD(lynes.1,1)='Mail:' & WORDS(lynes.2)>3 THEN
DO
IF DELETE(bbspath'EmailFiles/'WORD(lynes.3,2)'/'WORD(lynes.2,4))=1 THEN
SAY WORD(lynes.2,4) 'DELETED.'
END
RETURN 2
END
END
IF edcom='' THEN
DO
SAY ' 'pen3'Leaving the EDITOR module.'def
IF notchanged THEN RETURN 0
IF getinput(1 1 ' Save changes? (nY)'pen3' > 'def)='N' THEN
RETURN 1
CALL DELETE(editarg)
IF savelines(editarg) THEN RETURN 1
CALL DELAY(28)
IF finfo~='' THEN ADDRESS COMMAND 'C:filenote' editarg finfo
SAY pen3' Changes saved.'def
RETURN 0
END
ELSE IF edcom='C' THEN /* Cut */
DO
firstnum=getinput(1 0 ' Enter line number or range 'pen3'(5-7)'def' to cut' pen3'>'def)
IF firstnum='' THEN ITERATE edloop
dash=POS('-',firstnum)
IF dash>0 THEN
DO
lastnum=STRIP(SUBSTR(firstnum,dash+1))
firstnum=STRIP(LEFT(firstnum,dash-1))
END
ELSE lastnum=firstnum
IF ~DATATYPE(firstnum,'W') | ~DATATYPE(lastnum,'W') THEN
DO
junk=getinput(1 1 pen3'*** You must enter numbers here! 'def)
ITERATE edloop
END
IF lastnum>lynes.0 THEN lastnum=lynes.0
IF firstnum<firstedit THEN
DO
SAY '*** You are not authorized to delete that line!'
SAY
ITERATE edloop
END
IF firstnum>lastnum THEN
DO
SAY '*** Input error! First number larger than last number'
ITERATE edloop
END
notchanged=0
numdiff=lastnum+1-firstnum
pasted.=''
pasted.0=numdiff
k=0
DO i=firstnum TO lynes.0
j=i+numdiff
k=k+1
IF k<=numdiff THEN pasted.k=lynes.i
lynes.i=lynes.j
lynes.j=''
END
lynes.0=lynes.0-numdiff
count=1
END
ELSE IF edcom='A' THEN /* append */
DO
CALL writebuffer(scratch'/EditorLOCAL')
notchanged=0
END
ELSE IF edcom='U' THEN /* fileappend (upload) */
DO
frompath=GETCLIP('BBS_frompath')
IF frompath='' THEN frompath='RAM:'
farg=GetFile(150,36,frompath,'',' Select TextFile to Append ')
IF farg~='' & EXISTS(farg) THEN
DO
CALL readlines(farg lynes.0+1)
notchanged=0
CALL SETCLIP('BBS_frompath',WORD(lastslash(farg),2))
END
END
ELSE IF edcom='I' | edcom='R' | edcom='L' | edcom='P' | DATATYPE(edcom,'W') THEN
DO
IF DATATYPE(edcom,'W') THEN
DO
ednum=edcom
edcom='R'
END
ELSE
DO
line=pen3' '
IF edcom='L' | edcom='P' THEN line=line'Starting '
line=line'Line Number? > 'def
ednum=getinput(1 0 line)
END
IF ~DATATYPE(ednum,'W') THEN ITERATE edloop
IF ednum>(lynes.0+1) THEN ITERATE edloop
IF edcom='L' THEN
DO
count=ednum
ITERATE edloop
END
IF ednum<firstedit THEN
DO
SAY '*** You are not authorized to alter that line!'
SAY
ITERATE edloop
END
IF edcom='R' THEN /* replace */
DO
SAY ' Now reads:'
SAY pen3||RIGHT(ednum,2)||def lynes.ednum
OPTIONS PROMPT pen3'........Search text? >'def
PARSE PULL stext
IF LENGTH(stext)=0 THEN
DO
IF getinput(1 1 lineup||pen3'Replace entire line? (nY) >'def)='N' THEN
ITERATE edloop
lynes.ednum=getinput(0 0 pen3||RIGHT(ednum,2)' 'def)
notchanged=0
ITERATE edloop
END
found=POS(UPPER(stext),UPPER(lynes.ednum))
IF found=0 THEN
DO
SAY
SAY stext' was not found!'
SAY
ITERATE edloop
END
OPTIONS PROMPT pen3'...Replacement text? >'def
PARSE PULL rtext
lynes.ednum=DELSTR(lynes.ednum,found,LENGTH(stext))
lynes.ednum=INSERT(rtext,lynes.ednum,found-1)
SAY 'Done.'
SAY
notchanged=0
END
ELSE IF edcom='I' THEN /* insert */
DO
DO i=lynes.0 TO ednum BY -1
j=i+1
lynes.j=lynes.i
END
lynes.ednum=''
notchanged=0
lynes.0=lynes.0+1
lynes.ednum=getinput(0 0 pen3||RIGHT(ednum,2)'>'def)
END
ELSE IF edcom='P' THEN /* paste */
DO
DO i=lynes.0 TO ednum BY -1
j=i+pasted.0
lynes.j=lynes.i
END
DO k=1 TO pasted.0
kk=ednum+k-1
lynes.kk=pasted.k
END
notchanged=0
lynes.0=lynes.0+pasted.0
END
END
END
RETURN 0
lastslash: PROCEDURE
PARSE ARG sarg
sdir=''
slash=LASTPOS('/',sarg)
IF slash>2 THEN sdir=LEFT(sarg,slash-1)
ELSE
DO
slash=LASTPOS(':',sarg)
IF slash>0 THEN sdir=LEFT(sarg,slash)
END
IF slash>0 THEN sarg=SUBSTR(sarg,slash+1)
RETURN sarg sdir
countcheck:
PARSE ARG fname' 'cknum' '.
IF ~EXISTS(fname) THEN
DO
IF cknum=0 THEN RETURN 0
IF ~writeopen(fname) THEN RETURN 0
CALL WRITELN(f,cknum)
CALL CLOSE(f)
RETURN cknum
END
IF ~readopen(fname) THEN RETURN cknum
retval=STRIP(READLN(f))
CALL CLOSE(f)
IF ~DATATYPE(retval,'W') THEN retval=0
IF ~DATATYPE(cknum,'W') THEN cknum=0
IF retval<cknum THEN
DO
IF writeopen(fname) THEN
DO
CALL WRITELN(f,cknum)
CALL CLOSE(f)
RETURN cknum
END
END
RETURN retval
readopen:
PARSE ARG fname
ok=OPEN(f,fname,'R')
IF ok~=0 THEN RETURN 1
line=fname 'failed to open for reading!'
SAY line
RETURN 0
writeopen:
PARSE ARG fname
CALL CLOSE(f)
ok=OPEN(f,fname,'W')
IF ok~=0 THEN RETURN 1
line=fname 'failed to open for writing!'
SAY line
RETURN 0
writebuffer:
PARSE ARG bufname .
CALL DELETE(bufname)
startnum=lynes.0+1
OPTIONS PROMPT ''
SAY pen3'LOCAL logon! Input cannot exceed 250 characters per line!'def
SAY 'Type 'pen3'/E'def 'or' pen3'/S'def' on a new line to exit and' pen3'DO YOUR OWN WORDWRAP!'def
DO bufloop=startnum
PARSE PULL line
IF LEFT(UPPER(STRIP(line)),2)='/E' | LEFT(UPPER(STRIP(line)),2)='/S' THEN
LEAVE bufloop
lynes.bufloop=line
END
lynes.0=bufloop-1
CALL wrapbuf(startnum)
CALL DELETE(bufname)
CALL savelines(bufname)
CALL readlines(bufname 1)
CALL wrapbuf(startnum)
RETURN
wrapbuf:
ARG startnum .
SAY pen3'Wordwrapping...'def
lynes.startnum=TRANSLATE(lynes.startnum,' ','09'x)
lynes.startnum=COMPRESS(lynes.startnum,'0C'x) /* no FF */
DO wi=startnum WHILE wi<=lynes.0
wj=wi+1
lynes.wj=COMPRESS(lynes.wj,'08'x||'0C'x||'7F'x)
tabpos=POS('09'x,lynes.wi)
DO WHILE tabpos>0
lynes.wi=DELSTR(lynes.wi,tabpos,1)
lynes.wi=INSERT(' ',lynes.wi,tabpos-1)
tabpos=POS('09'x,lynes.wi)
END
IF LENGTH(lynes.wi)>75 THEN
DO
testchar=''
IF lynes.wj~='' THEN testchar=LEFT(lynes.wj,1)
IF testchar=' ' | testchar='.' | testchar=':' THEN
DO
DO wjj=lynes.0 TO wi+1 BY -1
wk=wjj+1
lynes.wk=lynes.wjj
END
lynes.wj=''
lynes.0=lynes.0+1
END
DO wl=WORDS(lynes.wi) TO 1 BY -1 WHILE LENGTH(lynes.wi)>74
IF WORDS(lynes.wi)=1 THEN
lynes.wi=LEFT(lynes.wi,74) SUBSTR(lynes.wi,75)
lynes.wj=WORD(lynes.wi,wl) lynes.wj
lynes.wi=STRIP(DELWORD(lynes.wi,wl,1))
END
END
END
RETURN
seelines:
DO i=1 TO lynes.0
SAY lynes.i||def
IF i//linesperpage=0 THEN
IF waiting2() THEN LEAVE i
END
nonstop=0
RETURN
readlines:
CALL CLOSE(f)
PARSE ARG tempname readstart .
IF ~readopen(tempname) THEN RETURN 1
IF readstart<2 THEN lynes.=''
DO ri=readstart
line=READLN(f)
IF EOF(f) THEN BREAK
lynes.ri=line
END
lynes.0=ri-1
CALL CLOSE(f)
DO ri=lynes.0 TO 0 BY -1 WHILE LENGTH(lynes.ri)=0 | LEFT(UPPER(lynes.ri),1)='/'
END
lynes.0=ri
RETURN 0
savelines:
PARSE ARG tempname .
ok=OPEN(f,tempname,'W')
IF ok=0 THEN
DO
SAY '***' tempname 'failed to open for saving!'
RETURN 1
END
DO wi=1 TO lynes.0
CALL WRITELN(f,lynes.wi)
END
CALL CLOSE(f)
RETURN 0
selectchosen:
PARSE ARG startnum selectline
SAY 'Enter a list of comma separated user names'
thechosen.startnum=getinput(1 0 selectline' ')
IF STRIP(thechosen.startnum)='' THEN RETURN 1
thechosen.startnum=SPACE(thechosen.startnum,1,'_')
thechosen.0=startnum
IF POS(',',thechosen.startnum)>0 THEN
DO
temp=TRANSLATE(thechosen.startnum,' ',',')
thechosen.0=thechosen.0+WORDS(temp)
DO ei=startnum TO startnum+WORDS(temp)
thechosen.ei=STRIP(WORD(temp,ei))
IF LEFT(thechosen.ei,1)='_' THEN
thechosen.ei=SUBSTR(thechosen.ei,2)
END
END
DO ei=1 TO thechosen.0
thechosen.ei=check_alias(thechosen.ei)
DO WHILE ~EXISTS(bbspath'Users/'thechosen.ei)
SAY thechosen.ei 'not found! Enter that name again or press RETURN.'
thechosen.ei=getinput(1 0 pen3||selectline' 'def)
thechosen.ei=cleanstring(thechosen.ei)
END
END
RETURN 0
cleanstring:
PARSE ARG cstr
cstr=TRANSLATE(cstr,,namemask)
cstr=SPACE(cstr,1,'_')
RETURN cstr
docity:
PARSE ARG citi
citi=TRANSLATE(citi,' ','+-.,*/()<>')
DO i=WORDS(citi) TO 1 BY -1
IF DATATYPE(WORD(citi,i),'N') THEN citi=STRIP(DELWORD(citi,i,1))
IF UPPER(WORD(citi,i))='USA' THEN citi=STRIP(DELWORD(citi,i,1))
END
citi=SPACE(citi,1)
RETURN STRIP(citi)
getinput:
PARSE ARG upflag' 'oneflag' 'pline
OPTIONS PROMPT pline
PARSE PULL inarg
inarg=STRIP(inarg)
IF upflag THEN inarg=UPPER(inarg)
IF oneflag THEN inarg=LEFT(inarg,1)
RETURN inarg
setdir:
PARSE ARG tempdir
CALL PRAGMA('D',STRIP(tempdir))
RETURN
waiting2:
IF nonstop=1 THEN RETURN 0
waitchar=getinput(1 1 pen3' Q=Quit N=Non-Stop RETURN=Continue 'def)
IF waitchar='N' THEN
DO
nonstop=1
SAY pen3'To EXIT non-stop scrolling of text, press CTRL-E 'def
SAY
CALL DELAY(100)
waitchar=''
END
IF waitchar='Q' THEN RETURN 1
RETURN 0
check_alias:
PARSE ARG ali .
IF ~DATATYPE(Friends.0,'W') THEN RETURN ali
DO ii=1 TO Friends.0
IF UPPER(WORD(Friends.ii,1))=UPPER(ali) THEN RETURN WORD(Friends.ii,2)
END
RETURN ali
showtext:
PARSE ARG arg .
IF EXISTS(arg) THEN
DO
CALL readlines(arg 1)
CALL seelines(1)
nonstop=0
CALL waiting()
END
RETURN
waiting:
IF waitchar='Q' THEN
DO
waitchar=''
RETURN
END
waitchar=''
IF nonstop=1 THEN RETURN
OPTIONS PROMPT pen3' RETURN=Continue 'def
PULL waitchar
RETURN
seeya:
SAY
SAY 'See ya.'
SAY
EXIT
/* bbsMail.rexx */