home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 2 BBS
/
02-BBS.zip
/
tmbnk210.zip
/
TIMEBANK.CMD
< prev
Wrap
OS/2 REXX Batch file
|
1992-09-28
|
13KB
|
327 lines
/* */
/* TimeBank Version 2.01
Rexx CMD file for a Time Bank for Maximus
by Edward Owens
of The Looking Glass
FidoNet 1:123/81
To run put the following line in your MENU.CTL file where you want it:
ReRead Xtern_Run TimeBank.cmd_%K_%P Normal "TimeBank"
Then replace the bbs and sysop variables immediately below and put
this CMD file in your Maximus directory. You may modify this in any way
your little heart's desires but do not distribute once modified. This is Freeware, there is no charge for it and I assume no responsibility for any
damage it may do. Have fun.*/
echo off
SIGNAL ON SYNTAX NAME usergone /* if remote & user hangsup, goto usergone. */
CALL init /* register extensions with REXX */
rc = RxAnsiInit() /* Set up ANSI variables */
ARG nodenum Commhndl
IF Commhndl ¬= '' THEN /* If remote user */
rc = RxMode(MIXED,Commhndl) /* set mode to mixed */
ELSE /* but if local */
rc = RxMouse(ON) /* turn on mouse support */
bbs="The Looking Glass" /* Replace with the name of your bbs */
sysop="Fast ED's" /* Replace with your name or handle */
maxtime=120 /* Maximum amount of time on account */
deptime=30 /* Maximum time deposit per day */
withtime=30 /* Maximum time withdrawal per day */
maxbytes=3000 /* Maximum Kbytes on account */
depbytes=300 /* Maximum Kbytes deposit per day */
withbytes=300 /* Maximum Kbytes withdrawal per day */
timeint=10 /* Interest rate per 30 days on time accounts */
byteint=10 /* Interest rate per 30 days on byte accounts */
/* userfile='lastuser.bbs' */
userfile=INSERT(nodenum,'lastus.bbs',6) /* Replace with above line if single node */
say testestetsets
rc=RXPUTCHARS(cls)
rc=RXGOTO(2,24)
rc=RXPUTCHARS(cyan'********************************')
rc=RXGOTO(3,24)
rc=RXPUTCHARS(cyan'*'yellow' Welcome to TimeBank 'cyan'*')
rc=RXGOTO(4,24)
rc=RXPUTCHARS(cyan'*'yellow' by Edward Owens 'cyan'*')
rc=RXGOTO(5,24)
rc=RXPUTCHARS(cyan'*'yellow' FidoNet 1:123/81 'cyan'*')
rc=RXGOTO(6,24)
rc=RXPUTCHARS(cyan'*'yellow' Written in REXX for OS/2 'cyan'*')
rc=RXGOTO(7,24)
rc=RXPUTCHARS(cyan'********************************')
rc=RXGOTO(15,1)
rc=RXPUTCHARS(green'Reading account information.......')
bankfile='timebank.dat'
usedbytes=0
privbytes=0
position=1
tempname=STRIP(CHARIN(userfile,1,36),,'00'x)
name=tempname
if \(SUBWORD(tempname,3,1)='') then
name=SUBWORD(tempname,1,1)' 'SUBWORD(tempname,2,1)SUBWORD(tempname,3,1)
timeleft=C2D(CHARIN(userfile,111,1)) + (C2D(CHARIN(userfile,112,1)) * 256)
priv=9-C2D(CHARIN(userfile,141,1))
if priv=-1 then priv=0
if priv<-1 then priv=10
do x=212 to 211 by -1
usedbytes=(usedbytes * 256) + C2D(CHARIN(userfile,x,1))
end /* do */
call LINEOUT(userfile)
if usedbytes>32767 then usedbytes=usedbytes-65536
do x=325+(priv*14) to 324+(priv*14) by -1
privbytes=(privbytes * 256) + C2D(CHARIN('max.prm',x,1))
end /* do */
call LINEOUT('max.prm')
bytes=privbytes-usedbytes
num=0
DO UNTIL (name=SUBWORD(acct.num,1,2)) | (LINES(bankfile)=0)
num=num + 1
acct.num=LINEIN(bankfile)
end /* do */
if (LINES(bankfile)=0) & \(name = SUBWORD(acct.num,1,2)) then do
banktime=0
bankbytes=0
ttime=withtime
tbytes=withbytes
okfile=LINEOUT(bankfile,name DATE(S) banktime bankbytes withtime withbytes)
call LINEOUT(bankfile)
end /* if */
else do
call LINEOUT(bankfile)
banktime=WORD(acct.num,4)
bankbytes=WORD(acct.num,5)
if DATE(S) = WORD(acct.num,3) then do
ttime=WORD(acct.num,6)
if ttime='' then ttime
tbytes=WORD(acct.num,7)
deptime=deptime+withtime-ttime
withtime=ttime
depbytes=depbytes+withbytes-tbytes
withbytes=tbytes
end /* if */
else do
day=WORD(acct.num,3)
today=DATE(S)
days=((LEFT(today,4)-LEFT(day,4))*360)+((SUBSTR(today,5,2)-SUBSTR(day,5,2))*30)+RIGHT(today,2)-RIGHT(day,2)
inttime=((days*banktime*timeint)%3000)
intbytes=((days*bankbytes*byteint)%3000)
banktime=banktime+inttime
bankbytes=bankbytes+intbytes
rc=RXGOTO(17,1)
rc=RXPUTCHARS(red'You have earned'yellow inttime red'since last time on for a balance of'cyan banktime)
rc=RXGOTO(18,1)
rc=RXPUTCHARS(red'You have earned'yellow intbytes red'since last time on for a balance of'cyan bankbytes)
rc=RXGOTO(20,1)
rc=RXPUTCHARS(magenta'Press any key for menu')
rc=RXGOTO(20,24)
rc=RXGETCHAR()
end /* else */
end /* else */
rc=RXPUTCHARS(cls intense)
rc=RXPUTCHARS(cyan" Welcome"magenta name cyan"to"magenta sysop cyan"Time Bank for Maximus OS/2")
rc=RXGOTO(4,27)
rc=RXPUTCHARS(white"D"magenta"eposit time")
rc=RXGOTO(5,27)
rc=RXPUTCHARS(white"W"magenta"ithdraw time")
rc=RXGOTO(6,27)
rc=RXPUTCHARS(white"P"magenta"ut some Kbytes in")
rc=RXGOTO(7,27)
rc=RXPUTCHARS(white"G"magenta"et some Kbytes out")
rc=RXGOTO(8,27)
rc=RXPUTCHARS(white"S"magenta"peedy maximum deposits")
rc=RXGOTO(9,27)
rc=RXPUTCHARS(white"Q"magenta"uit back to "bbs)
rc=RXGOTO(15,25)
rc=RXPUTCHARS(cyan'What would you like to do?'white)
DO UNTIL (choice='Q') | (choice='q')
rc=RXGOTO(17,9)
rc=RXPUTCHARS(' ')
rc=RXGOTO(18,9)
rc=RXPUTCHARS(' ')
rc=RXGOTO(19,9)
rc=RXPUTCHARS(' ')
rc=RXGOTO(12,10)
rc=RXPUTCHARS(yellow'You have'white banktime yellow'minutes on account and'white timeleft yellow'minutes left on BBS ')
rc=RXGOTO(13,10)
rc=RXPUTCHARS(yellow'You have'white bankbytes yellow'Kbytes on account and'white bytes yellow'Kbytes left on BBS 'white)
rc=RXGOTO(15,52)
choice=RXGETCHAR()
rc=RXPUTCHARS()
rc=RXPUTCHARS()
select
when (choice='D') | (choice='d') then do
rc=RXGOTO(17,9)
rc=RXPUTCHARS(magenta'You have'white banktime magenta'minutes on account and'white timeleft magenta'minutes left.')
rc=RXGOTO(18,9)
rc=RXPUTCHARS(cyan'Maximum on account is'yellow maxtime cyan'and maximum deposit is'yellow deptime)
rc=RXGOTO(19,9)
rc=RXPUTCHARS(red'How much would you like to deposit?'blue)
amount=RXGETCHARS(19,45,4,deptime)
if (datatype(amount,'W')) & (amount>0) then do
if amount>timeleft then amount=timeleft
if amount>deptime then amount=deptime
if (amount+banktime>maxtime) then amount=maxtime-banktime
timeleft=timeleft-amount
banktime=banktime+amount
deptime=deptime-amount
withtime=withtime+amount
if timeleft=0 then choice='Q'
end
end
when (choice='W') | (choice='w') then do
rc=RXGOTO(17,9)
rc=RXPUTCHARS(magenta'You have'white banktime magenta'minutes on account and'white timeleft magenta'minutes left.')
rc=RXGOTO(18,9)
rc=RXPUTCHARS(cyan'Maximum withdrawal is'yellow withtime)
rc=RXGOTO(19,9)
rc=RXPUTCHARS(red'How much would you like to withdraw?'blue)
amount=RXGETCHARS(19,46,4,withtime)
if (datatype(amount,'W')) & (amount>0) then do
if amount>banktime then amount=banktime
if amount>withtime then amount=withtime
deptime=deptime+amount
withtime=withtime-amount
timeleft=timeleft+amount
banktime=banktime-amount
end
end
when (choice='P') | (choice='p') then do
rc=RXGOTO(17,9)
rc=RXPUTCHARS(magenta'You have'white bankbytes magenta'Kbytes on account and'white bytes magenta'Kbytes left.')
rc=RXGOTO(18,9)
rc=RXPUTCHARS(cyan'Maximum on account is'yellow maxbytes cyan'and maximum deposit is'yellow depbytes)
rc=RXGOTO(19,9)
rc=RXPUTCHARS(red'How much would you like to deposit?'blue)
amount=RXGETCHARS(19,45,5,depbytes)
if (datatype(amount,'W')) & (amount>0) then do
if amount>bytes then amount=bytes
if amount>depbytes then amount=depbytes
if (amount+bankbytes>maxbytes) then amount=maxbytes-bankbytes
depbytes=depbytes-amount
withbytes=withbytes+amount
bytes=bytes-amount
bankbytes=bankbytes+amount
end
end
when (choice='G') | (choice='g') then do
rc=RXGOTO(17,9)
rc=RXPUTCHARS(magenta'You have'white bankbytes magenta'Kbytes on account and'white bytes magenta'Kbytes left.')
rc=RXGOTO(18,9)
rc=RXPUTCHARS(cyan'Maximum withdrawal is'yellow withbytes)
rc=RXGOTO(19,9)
rc=RXPUTCHARS(red'How much would you like to withdraw?'blue)
amount=RXGETCHARS(19,46,5,withbytes)
if (datatype(amount,'W')) & (amount>0) then do
if amount>bankbytes then amount=bankbytes
if amount>withbytes then amount=withbytes
depbytes=depbytes+amount
withbytes=withbytes-amount
bytes=bytes+amount
bankbytes=bankbytes-amount
end
end
when (choice='S') | (choice='s') then do
rc=RXGOTO(17,9)
rc=RXPUTCHARS('Making maximum time deposit and byte deposit')
if timeleft>deptime then amount=deptime
else amount=timeleft
if (amount+banktime>maxtime) then amount=maxtime-banktime
rc=RXGOTO(18,9)
rc=RXPUTCHARS('Deposited' amount 'minutes')
timeleft=timeleft-amount
banktime=banktime+amount
deptime=deptime-amount
withtime=withtime+amount
if bytes>depbytes then amount=depbytes
else amount=bytes
if (amount+bankbytes>maxbytes) then amount=maxbytes-bankbytes
rc=RXGOTO(19,9)
rc=RXPUTCHARS('Deposited' amount 'Kbytes')
depbytes=depbytes-amount
withbytes=withbytes+amount
bytes=bytes-amount
bankbytes=bankbytes+amount
choice='Q'
end
otherwise NOP
end /* select */
end
rc=RXGOTO(21,1)
rc=RXPUTCHARS(cyan'Returning you to 'yellow bbs reset)
timeout = d2c(timeleft//256)
okfile = CHAROUT(userfile,timeout,111)
timeout = d2c(timeleft%256)
okfile = CHAROUT(userfile,timeout,112)
usedbytes=privbytes-bytes
bytesout=d2c(0)
if usedbytes<0 then do
bytesout=d2c(255)
usedbytes=65536+usedbytes
end
okfile=CHAROUT(userfile,bytesout,214)
okfile=CHAROUT(userfile,bytesout,213)
do x=211 to 212 by 1
bytesout= d2c(usedbytes//256)
usedbytes= usedbytes%256
okfile = CHAROUT(userfile,bytesout,x)
end /* do */
'ren' bankfile 'timebank.tmp'
DO UNTIL (LINES('timebank.tmp')=0)
account=LINEIN('timebank.tmp')
if (name=SUBWORD(account,1,2)) then
okfile=LINEOUT(bankfile,name DATE(S) banktime bankbytes withtime withbytes)
else okfile=LINEOUT(bankfile, account)
end /* do */
call LINEOUT(bankfile)
call LINEOUT('timebank.tmp')
'del timebank.tmp'
rc=RXPUTCHARS(cls)
CALL term
return
/* --------------------------------------------------------------------- */
/* Remote user has hung up - tell host and quit */
/* --------------------------------------------------------------------- */
usergone:
IF lastkey = 'USER GONE' THEN
SAY 'User gone'
ELSE
SAY 'Bug in your Rexx procedure'
CALL term
RETURN
/* --------------------------------------------------------------------- */
/* Register all the functions to REXX */
/* --------------------------------------------------------------------- */
init : procedure
CALL RxFuncAdd 'RXANSIINIT','RXANSI','RXANSIINIT'
CALL RxFuncAdd 'RXGOTO', 'RXANSI','RXGOTO'
CALL RxFuncAdd 'RXMODE', 'RXANSI','RXMODE'
CALL RxFuncAdd 'RXMOUSE', 'RXANSI','RXMOUSE'
CALL RxFuncAdd 'RXLINE', 'RXANSI','RXLINE'
CALL RxFuncAdd 'RXLINETYPE','RXANSI','RXLINETYPE'
CALL RxFuncAdd 'RXHMENU', 'RXANSI','RXHMENU'
CALL RxFuncAdd 'RXVMENU', 'RXANSI','RXVMENU'
CALL RxFuncAdd 'RXBOX', 'RXANSI','RXBOX'
CALL RxFuncAdd 'RXGETCHAR', 'RXANSI','RXGETCHAR'
CALL RxFuncAdd 'RXGETCHARS','RXANSI','RXGETCHARS'
CALL RxFuncAdd 'RXPUTCHARS','RXANSI','RXPUTCHARS'
RETURN
/* --------------------------------------------------------------------- */
/* Deregister all the functions from REXX */
/* --------------------------------------------------------------------- */
term : procedure
CALL RxFuncDrop 'RXANSIINIT'
CALL RxFuncDrop 'RXGOTO'
CALL RxFuncDrop 'RXMODE'
CALL RxFuncDrop 'RXMOUSE'
CALL RxFuncDrop 'RXLINE'
CALL RxFuncDrop 'RXLINETYPE'
CALL RxFuncDrop 'RXHMENU'
CALL RxFuncDrop 'RXBOX'
CALL RxFuncDrop 'RXGETCHAR'
CALL RxFuncDrop 'RXGETCHARS'
CALL RxFuncDrop 'RXPUTCHARS'
RETURN