home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 1: Amiga
/
FrozenFish-Apr94.iso
/
bbs
/
alib
/
d9xx
/
d950
/
bbdoors.lha
/
BBDoors
/
BBDoors65.lha
/
rexxDoors
/
Number_Guesser.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1993-08-08
|
5KB
|
194 lines
/* The WORLD FAMOUS ARexx Number Guesser v2.2c
Written by Charles Johnston of CrazySoft Inc. Prescott,AZ (03-08-93)
FREELY DISTRIBUTABLE as long as this notice remains
Comments may be sent to Charles (Sysop) Crazy Train BBS (602)771-8971*/
CR="0D"x
CALL TIME('R')
SIGNAL ON BREAK_C
SIGNAL ON BREAK_E
CLS=d2c(12)
PARSE arg Username winnings . colorflag secs .
IF ~DATATYPE(secs,'N') THEN secs=3600
def=''
red=''
grn=''
yel='' /*Turns off ANSI codes but then checks users colorflag below*/
blu=''
mag=''
cyn=''
wht=''
IF colorflag=1 THEN /* let's see some color!*/
DO
def=''
red='
'
grn='
'
yel='
'
blu='
'
mag='
'
cyn='
'
wht='
'
END
bbspath=GETCLIP('BBS_path') /*retrieve bbs path so our prg is generic*/
filename=bbspath'rexxDoors/data/top10'
If ~exists(filename) then
do
call open('top10',filename,'w')
do 10
line = '9 Charles_Johnston'
call writeln('top10',line)
end
call close('top10')
end
call message cls
say ''||CR
IF OPEN('top10',filename,'r') THEN
DO
DO m = 1 TO 10 UNTIL EOF('top10')
line.m = readln('top10')
END
CALL CLOSE('top10')
m = m - 1
END
name = UPPER(username)
call message cls
say ''||CR
options prompt mag'Would you like to see the TOP TEN scores' name'?'
pull answer
say ''||CR
if answer ~='Y' then call start
if answer = 'Y' then CALL Showtop10()
say ''||CR
options prompt yel'Are you ready to play' name'? (Y/N)'
pull answer
if answer ~='Y' then call OUT
else call start
start:
call message cls
answer = random(1,1000,time(s))
say wht' ---------------------------------------------------------------------'||CR
say wht' | |'||CR
say wht' |'red' -----=====>>>>>' wht' N U M B E R G U E S S E R 'red ' <<<<<=====-----'wht' |'||CR
say wht' | |'||CR
say wht' |'yel' Ver 2.2c -'grn' Written for Baud Bandit BBS'yel' - by Charles Johnston'wht' |'||CR
say wht' |'mag' CrazySoft Inc.'cyn' Prescott,Arizona'wht' |'||CR
say wht' | |'||CR
say wht' ---------------------------------------------------------------------'||CR
say ''||CR
say yel' I am thinking of a number between 1 and 1000....You get 10 turns!'||CR
do number = 1 to 10 until guess = answer
CALL checkBBS()
say ''||CR
Options prompt mag' Q=Quit'wht' OR 'red' Enter Your Guess => '
pull guess
remaining = 11 - (number+1)
if guess = 'Q' then call OUT
if answer > guess then
say yel' 'guess''wht' is just a little bit too'grn' LOW!....'yel''remaining''wht' turns left'||CR
else if answer < guess then
say yel' 'guess''wht' is just a little bit too 'mag'HIGH!...'yel''remaining''wht' turns left'||CR
end
if guess ~= answer then
do
say ''||CR
say red' You used all'mag' 10'red' turns!'||CR
say wht' Better luck'yel' NEXT'wht' time!'||CR
say grn' The'yel' correct'grn' number was'yel'' answer '!'||CR
end
else
do
say ''||CR
say wht' You got it in'red'' number ''wht'turns!'||CR
call delay(200)
/* Sort and add to list only if it is better than 10th score */
IF number < number.10 & number < 10 THEN
DO
line.10 = number' 'name
CALL is(1, m)
CALL Showtop10()
CALL DELETE(filename)
CALL OPEN('top10',filename,'w')
DO i = 1 TO m
CALL WRITELN('top10',line.i)
END
call close('top10')
END
END
say ''||CR
Options prompt cyn' Would you like to try again?'grn' > '
pull again
if again = 'Y' then call start
if again ~= 'Y' then call OUT
else
BREAK_C:
BREAK_E:
exit
checkBBS:
IF ADDRESS()~='BAUD' THEN RETURN 0
IF TIME('E')>secs THEN SIGNAL OUT
dcd
IF RC=0 THEN EXIT
temp=secs-TIME('E')
IF temp<120 THEN SAY '*** Only' temp 'seconds left! ***'CR
RETURN 0
/* Insertion Sort */
/* line s list to be sorted, start should be 1, end is max number of lines */
/* line is a compound variable from line.1 to line.end */
is:
DO i = 2 to m
x = line.i
j = i - 1
DO WHILE j > 0 & x < line.j
k = j + 1
line.k = line.j
j = j - 1
END
k = j + 1
line.k = x
END
RETURN
Showtop10:
say'0C'x
say mag CENTER(' *******************************************',75)||CR
say ''||CR
say wht CENTER(' N U M B E R G U E S S E R ',75)||CR
say ''||CR
SAY mag CENTER(' ********** Top'yel' TEN'mag' Hall of Fame ********',75)||def||CR
say ''||CR
DO i = 1 TO m
PARSE VAR line.i number.i name.i
name.i = COPIES(' ',24)name.i
number = COPIES(' ',52)number.i
SAY''OVERLAY(name.i, number)''cr
END
RETURN
message:
parse arg string
say string||CR
return
out:
call message cls
say mag' Now returning to BBS.....'
exit