home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Fish 2
/
goldfish_vol2_cd1.bin
/
files
/
comm
/
bbs
/
bbbbs
/
bbbbs72.lha
/
rexx
/
bbsFile.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1994-04-16
|
27KB
|
1,128 lines
/* $VER: bbsFile.rexx 7.2 (16.4.94) Copyright © 1994 Richard Lee Stockton
* BBBBS local file uploader
* FREELY DISTRIBUTABLE
*/
kill_original=0 /* To "move" files, set this to 1 */
IF ~SHOW('P','QuickSortPort') THEN CALL setup.rexx()
IF ~SHOW('P','QuickSortPort') THEN EXIT 666
CALL OPENPORT('BBSFILE')
title.=''
title.1='BBBBS File Uploader'
title.2='Version 7.1'
title.3='7-Mar-94'
def=''
pen2='
'
pen3='
'
lineup='1B'x'M'
newlist.=''
newlist.0=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'/'
libpath=WORD(lynes.8,1)
IF ~EXISTS(libpath) THEN
DO
SAY libpath 'does not exist!'
EXIT
END
testchar=RIGHT(libpath,1)
IF testchar~='/' & testchar~=':' THEN libpath=libpath'/'
IF WORD(lynes.25,1)=1 THEN scratch=bbspath'Scratch'
ELSE scratch='RAM:Scratch'
CALL MAKEDIR(scratch)
extension=WORD(lynes.32,1)
compos=POS('/*',lynes.33)
IF compos>0 THEN lynes.33=LEFT(lynes.33,compos-1)
arccom=STRIP(lynes.33)
IF LEFT(extension,1)~='.' THEN
DO
extension='.lzh'
arccom='lharc -m m'
END
OPTIONS PROMPT ' Are you 'sysop'? (Yn) > '
PULL answer
IF answer='N' THEN
DO
SAY
OPTIONS PROMPT ' Please enter your name > '
PULL name
name=cleanstring('1:'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
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
SAY
SAY' OK, 'name' here we go....'
SAY
dirs.=''
IF readopen(bbspath'Lists/Libraries') THEN
DO
SAY 'Loading library list...'
DO i=1
line=READLN(f)
IF line='END' | EOF(f) THEN LEAVE i
num=WORD(line,1)
IF DATATYPE(num,'W') THEN dirs.num=STRIP(WORD(line,2))
END
CALL CLOSE(f)
CALL sortlibraries()
END
SAY
DO FOREVER
SAY
DO i=1 TO 3
SAY CENTER(title.i,24)
END
SAY
IF uload()>1 THEN CALL seeya
END
/* SUBROUTINES */
sortlibraries:
SAY 'Sorting Libraries...'
count=0
sdirs.=''
DO i=1 TO level
IF dirs.i='' THEN ITERATE i
count=count+1
sdirs.count=dirs.i i
END
sdirs.0=count
IF count>0 THEN CALL QSort(1,count,sdirs)
count=0
libs.=''
DO i=1 TO sdirs.0
tempnum=WORD(sdirs.i,2)
tempdir=WORD(sdirs.i,1)
IF FIND(data.21,UPPER(tempdir))=0 THEN
DO
string=' '
IF tempnum<10 THEN string=string' '
string=string || tempnum'. 'LEFT(tempdir,14)
count=count+1
libs.count=string
END
END
libs.0=count%4
IF (count//4)>0 THEN libs.0=libs.0+1
DO i=1 TO libs.0
DO j=1 TO 3
k=i+j*libs.0
IF k<=count THEN libs.i=libs.i||libs.k
END
END
DROP sdirs.
RETURN
bbsspace:
ARG tabspace .
ADDRESS COMMAND 'C:info >ram:filinfout' bbsdevice
ok=OPEN(f,'ram:filinfout','R')
IF ok=0 THEN RETURN 20
line=READLN(f)
line=READLN(f)
line=READLN(f)
line=READLN(f)
CALL CLOSE(f)
IF tabspace<14 THEN SAY
bbsk=WORD(line,4)
IF ~DATATYPE(bbsk,'N') THEN
DO
line=bbsdevice 'is not an info compatible device!'
SAY pen3||line||def
bbsk=0
RETURN
END
bbsk=bbsk*512
IF bbsk<1 THEN bbsk=0
SAY RIGHT(comma(bbsk),tabspace) 'bytes available for uploads.'
RETURN
comma:
ARG num .
dgt=LENGTH(num)
numtext=''
IF dgt>3 THEN numtext=','RIGHT(num,3)
IF dgt>6 THEN numtext=','LEFT(RIGHT(num,6),3)||numtext
IF dgt>9 THEN numtext=','LEFT(RIGHT(num,9),3)||numtext
IF dgt>12 THEN
DO
numtext=','LEFT(RIGHT(num,12),3)||numtext
numtext=LEFT(num,dgt-12)||numtext
END
ELSE IF dgt>9 THEN numtext=LEFT(num,dgt-9)||numtext
ELSE IF dgt>6 THEN numtext=LEFT(num,dgt-6)||numtext
ELSE IF dgt>3 THEN numtext=LEFT(num,dgt-3)||numtext
ELSE numtext=num
RETURN numtext
is_here:
ARG newname
SAY 'Checking filelist...'
DO wi=1 TO 99
IF wi//3=0 THEN CALL WRITECH(STDOUT,'.')
IF dirs.wi='' THEN ITERATE wi
IF ~EXISTS(bbspath'FileNotes/'dirs.wi'/'newname) THEN ITERATE wi
line=pen3'*** File' newname 'already exists here'
IF wi<=level THEN line=line 'in the' dirs.wi 'library'
line=line'.'def
SAY line
SAY 'Original uploader should ['pen3'K'def']ill the file before uploading the replacement.'
CALL waiting()
RETURN 1
END
RETURN 0
uload:
CALL bbsspace(12)
SAY
IF bbsk<1 THEN
DO
SAY pen3'Upload area is full!'def
RETURN 2
END
frompath=GETCLIP('BBS_frompath')
IF frompath='' THEN frompath='RAM:'
fdir=''
DO loop=1
fromfile=GetFile(200,,frompath,'',' Select File to Upload ')
IF fromfile='' THEN RETURN 3
finfo=STATEF(fromfile)
IF WORD(finfo,1)='DIR' THEN RETURN 3
IF WORD(finfo,1)='FILE' THEN LEAVE loop
SAY
SAY fromfile 'does not exist!'
CALL DELAY(100)
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
arg=COMPRESS(arg,' :/,;|#?*()+[]"{}') /* be sure no illegals here */
x=LASTPOS('/',fromfile)
IF x=0 THEN x=LASTPOS(':',fromfile)
IF x>0 THEN
DO
IF DATATYPE(SUBSTR(fromfile,x+1),'W') THEN
DO
SAY 'Whole numbers are not allowed as filenames!'
CALL waiting()
RETURN 1
END
END
size=WORD(STATEF(fromfile),2)
IF ~DATATYPE(size,'W') THEN size='654321'
tempnum=LENGTH(arg)+LENGTH(size)-22
DO WHILE tempnum>0
temp=' 'pen3||arg def'is'pen3 tempnum||def
IF tempnum=1 THEN temp=temp 'character'
ELSE temp=temp 'characters'
temp=temp 'too long for a filename.'
SAY temp
arg=getinput(0 0 'Filename: ')
arg=cleanstring('0:'arg)
arg=COMPRESS(arg,' :/,;|#?*')
tempnum=LENGTH(arg)+LENGTH(size)-22
END
IF arg='' THEN RETURN 1
IF is_here(arg) THEN RETURN 1
IF bbsprefs.6=1 & sysoplevel>level THEN CALL setdir(libpath'Sysops')
ELSE
DO
SAY
SAY 'Please select an appropriate library for -' pen3||arg def'-'
IF chdir()>0 THEN RETURN 1
END
ADDRESS COMMAND 'C:COPY' fromfile PRAGMA('D')'/'arg
IF TestArc.rexx(PRAGMA('D')'/'arg)>0 THEN
DO
SAY
SAY pen3'***'def arg pen3'failed archive check!'def
SAY
temp=getinput(1 1 'Do you believe the archive checker made a mistake? (Ny) > ')
IF temp~='Y' THEN
DO
CALL DELETE(arg)
SAY
RETURN 1
END
END
IF kill_original THEN
DO
CALL DELETE(fromfile)
SAY 'Killed' fromfile'...'
END
DO ui=sysoplevel+2 TO 100
IF UPPER(dirs.ui)=UPPER(plaindir) THEN RETURN 0
END
DO WHILE editnote(bbspath'FileNotes/'plaindir'/'arg) /* INSIST on a filenote */
END
RETURN 0
editnote:
IF arg='' THEN
DO
PARSE PULL arg .
IF arg='' THEN RETURN 0
END
comment=''
IF ~EXISTS(arg) THEN
DO
finfo=STATEF(bbspath'FileNotes/'plaindir'/'arg)
fromarg=arg
fromdir=GETCLIP('BBS_frompath')
IF WORDS(finfo)>7 THEN
DO
temp='Y'
fromdir=WORD(finfo,8)
fromdir=lastslash(fromdir)
fromarg=WORD(fromdir,1)
fromdir=WORD(fromdir,2)
END
ELSE
DO
IF level<sysoplevel THEN RETURN 0
temp=getinput(1 1 'Is this file on an another device? (Nqy)')
END
IF fromdir='' THEN fromdir='RAM:'
IF temp='Y' THEN
DO WHILE comment=''
comment=GetFile(150,36,fromdir,fromarg,' Select Linked File ')
IF comment='' THEN RETURN 0
IF ~EXISTS(comment) THEN comment=''
ELSE CALL SETCLIP('BBS_frompath',WORD(lastslash(comment),2))
END
ELSE IF temp~='N' THEN RETURN 0
END
filedir=plaindir
slash=LASTPOS('/',arg)
IF slash=0 THEN slash=LASTPOS(':',arg)
IF slash>0 THEN
DO
filedir=LEFT(arg,slash-1)
filedir=SUBSTR(filedir,5)
arg=SUBSTR(arg,slash+1)
END
ELSE filedir=plaindir
CALL MAKEDIR(bbspath'FileNotes/'filedir)
IF ~EXISTS(bbspath'FileNotes/'filedir) THEN
DO
SAY pen3'*** Failed to open directory!' filedir||def
RETURN 0
END
notename=bbspath'FileNotes/'filedir'/'arg
lynes.=''
filenum=countcheck(bbspath'Numbers/LastFile' 0)
IF level>sysoplevel THEN firstedit=1
ELSE firstedit=5
IF EXISTS(notename) THEN
DO
IF comment~='' THEN ADDRESS COMMAND 'C:filenote' notename comment
CALL bbsED(firstedit notename)
RETURN 0
END
IF comment='' THEN filedata=STATEF(libpath||filedir'/'arg)
ELSE filedata=STATEF(comment)
IF filedata='' THEN
DO
IF comment='' THEN line=filedir'/'arg
ELSE line=comment
SAY line 'does not exist!'
RETURN 0
END
bytes=WORD(filedata,2)
filenum=filenum+1
lynes.0=4
lynes.1='File: 'LEFT(filenum,5)' KeyWords:'
lynes.2='Name: 'LEFT(arg,27)' Size: 'bytes' bytes Downloads: 0'
lynes.3='From: 'LEFT(name,27)' Date: 'DATE() TIME('C')' Lib: 'filedir
lynes.4=LEFT('',74,'=')
lynes.1=lynes.1 edkeywords(arg filedir)
CALL seelines(1)
edtype=''
CALL writebuffer(scratch'/NoteFile')
IF savelines(notename) THEN RETURN 0
IF comment~='' THEN ADDRESS COMMAND 'C:filenote' notename comment
fncom='R'
DO WHILE fncom='R'
CALL seelines(1)
nonstop=0
line='['pen3'E'def']dit'
IF level>sysoplevel THEN line=line '['pen3'K'def']ill'
line=line '['pen3'R'def']ead ['pen3'S'def']ave'
IF level>sysoplevel THEN line=line '(ekrS) 'def
ELSE line=line '(erS) 'def
fncom=getinput(1 1 line)
IF fncom='K' & level>sysoplevel THEN
DO
SAY 'Killing FileNote..'
CALL DELETE(notename)
RETURN 1
END
ELSE IF fncom='E' THEN
DO
IF bbsED(firstedit notename)>0 THEN RETURN 0
fncom='R'
END
ELSE IF fncom~='R' THEN
DO
SAY 'Adjusting filelist...'
IF filenum<1 THEN filenum=1
IF GETCLIP('BBS_level')~='' THEN CALL SETCLIP('BBS_localfiles',1)
CALL countcheck(bbspath'Numbers/LastFile' filenum)
IF EXISTS(bbspath'Lists/Files') THEN
x=OPEN(f,bbspath'Lists/Files','A')
ELSE x=OPEN(f,bbspath'Lists/Files','W')
IF x=0 THEN
DO
SAY '*** Failed to open' bbspath'Lists/Files'
RETURN 0
END
CALL WRITELN(f,filenum plaindir arg)
CALL CLOSE(f)
libnum=finddirnum(plaindir)
PARSE VAR lynes.1 . 'KeyWords:' keywords
alpha=LEFT(arg,22-LENGTH(WORD(lynes.2,4)))
alpha=alpha WORD(lynes.2,4) RIGHT(filenum,5)
alpha=alpha RIGHT(libnum,2) LEFT(plaindir,12)
alpha=alpha STRIP(LEFT(STRIP(keywords),32))
IF SHOW('P','BBBBS') THEN CALL SETCLIP('BBS_localfiles',1)
IF SHOW('P','BBBBS_LOCAL') THEN CALL SETCLIP('BBS_mainfiles',1)
newlist.0=newlist.0+1
nl=newlist.0
newlist.nl=alpha
SAY alpha
tf=bbspath'Lists/Files.ALPHA.add'
IF EXISTS(tf) THEN ft='A'
ELSE ft='W'
x=OPEN(a,tf,ft)
IF x=0 THEN SAY 'Unable to open File.ALPHA.add for writing!'
ELSE
DO
CALL WRITELN(a,alpha)
CALL CLOSE(a)
END
END
END
RETURN 0
edkeywords:
PARSE ARG kwarg
templine=''
DO WHILE LENGTH(templine)<3
SAY
SAY pen3'Please enter a list of keywords (or a condensed description)'def
SAY pen3'to be used in the alphabetic list and by the search routine.'def
SAY ' Note that only the first 32 characters will be used.'
SAY LEFT('',43)'|'LEFT('',31,'=')'|'
templine=getinput(0 0 ' 'RIGHT(STRIP(RIGHT(kwarg,32)),32) pen3'KeyWords: 'def)
templine=cleanstring('0:'templine)
templine=STRIP(LEFT(templine,32))
SAY
END
RETURN templine
loadfiles:
SAY def
SAY 'Loading filelist...'
files.=''
files.0=0
IF readopen(bbspath'Lists/Files') THEN
DO
DO i=1
line=READLN(f)
IF EOF(f) THEN LEAVE i
num=WORD(line,1)
IF DATATYPE(num,'W') THEN files.num=WORD(line,2) WORD(line,3)
END
files.0=i-1
CALL CLOSE(f)
END
RETURN
savefilelist:
SAY 'Saving filelist...'
xarg=bbspath'Lists/Files'
CALL DELETE(xarg)
filenum=countcheck(bbspath'Numbers/LastFile' 0)
IF filenum<1 | writeopen(xarg)=0 THEN RETURN
DO i=1 TO filenum
IF files.i='' THEN ITERATE
CALL WRITELN(f,i files.i)
END
CALL CLOSE(f)
RETURN
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=libpath'SysOps'
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
cleanstring:
PARSE ARG nflag':'cstr
IF nflag=1 THEN
DO
cstr=COMPRESS(cstr,"'`")
cstr=TRANSLATE(cstr,,namemask)
cstr=SPACE(cstr,1,'_')
RETURN cstr
END
bot=XRANGE(,'1F'x)
top=XRANGE('7F'x)
cstr=COMPRESS(cstr,bot||top)
IF nflag=0 THEN cstr=STRIP(cstr)
RETURN cstr
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))
directory=PRAGMA('D')
slash=LASTPOS('/',directory)
IF slash=0 THEN slash=LASTPOS(':',directory)
plaindir=directory
IF slash>0 THEN plaindir=SUBSTR(plaindir,slash+1)
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
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
finddirnum:
ARG fdirname .
DO fdir=1 TO 99
IF UPPER(dirs.fdir)=UPPER(fdirname) THEN RETURN fdir
END
RETURN 100
chdir:
string=''
SAY pen3||LEFT('-',75,'-')||def
DO i=1 TO libs.0
SAY libs.i
END
dirnum=getinput(1 0 pen3'Select Library Number: 'def)
IF ~DATATYPE(dirnum,'W') THEN
DO
waitchar=dirnum
RETURN 2
END
IF dirnum<1 | dirnum>99 THEN
DO
waitchar=dirnum
RETURN 1
END
IF dirs.dirnum='' THEN
DO
SAY pen3'That library number is currently un-assigned.'def
RETURN 1
END
IF dirnum>level | FIND(data.21,UPPER(dirs.dirnum))>0 THEN
DO
SAY pen3'You do not have authorization for that library!'def
RETURN 1
END
CALL MAKEDIR(libpath||dirs.dirnum)
CALL setdir(libpath||dirs.dirnum)
t=libpath||plaindir'.txt'
IF ~EXISTS(t) THEN RETURN 0
nonstop=1
SAY
CALL readlines(t 1)
CALL seelines(1)
SAY
nonstop=0
RETURN 0
seeya:
IF newlist.0>0 THEN
DO
IF newlist.0>1 THEN CALL QSort(1,newlist.0,newlist)
SAY 'Loading Files.ALPHA...'
x=OPEN(f,bbspath'Lists/Files.ALPHA','R')
IF x=0 THEN
DO
SAY 'Unable to open File.ALPHA for reading!'
EXIT 666
END
a.=''
DO i=1
line=READLN(f)
IF EOF(f) THEN LEAVE i
a.i=line
END
CALL CLOSE(f)
a.0=i-1
CALL DELAY(128)
x=OPEN(f,bbspath'Lists/Files.ALPHA','W')
IF x=0 THEN
DO
SAY 'Unable to open File.ALPHA for writing!'
EXIT 666
END
nl=1
SAY 'Writing new Files.ALPHA list...'
DO i=1 TO a.0
IF nl<=newlist.0 THEN
DO
IF UPPER(newlist.nl)<UPPER(a.i) THEN
DO
SAY newlist.nl
CALL WRITELN(f,newlist.nl)
nl=nl+1
END
END
CALL WRITELN(f,a.i)
END
CALL CLOSE(f)
tf=bbspath'Lists/Files.ALPHA.add'
IF EXISTS(tf) THEN CALL DELETE(tf)
CALL bbsALPHA.rexx(SUBSTR(extension,2) arccom)
IF SHOW('P','BBBBS') THEN CALL SETCLIP('BBS_localfiles',2)
ELSE CALL SETCLIP('BBS_localfiles')
IF SHOW('P','BBBBS_LOCAL') THEN CALL SETCLIP('BBS_mainfiles',2)
ELSE CALL SETCLIP('BBS_mainfiles')
END
SAY
SAY 'See ya.'
SAY
EXIT
/* bbsFile.rexx */