home *** CD-ROM | disk | FTP | other *** search
-
- REM $option k10
- REM $option y+,v+,u+,[,]
-
- DEF FNgen
- STATIC y
-
- DO
- y=CINT(RND*1000)
- LOOP UNTIL y<1000 AND y>0
- FNgen=y
-
- END DEF
-
- SUB game
- STATIC num,low,high,turn,a,a$
-
- RANDOMIZE
-
- num=FNgen
-
- turn=0
- low=1
- high=999
-
- DO
- INCR turn
- PRINT "Turn:";turn
- PRINT "The number is between";low;"and";high
- PRINT
-
- INPUT "What do you think the number is? ",a
-
- IF a>999 THEN STOP
- IF a<num THEN PRINT "The number is greater than";a : IF a>low THEN low=a
- IF a>num THEN PRINT "The number is below";a : IF a<high THEN high=a
- IF a=num THEN
- PRINT
- PRINT "Congratulations! The number was";num;"and you guessed correctly in";turn;"turns!" : a=1000
- PRINT
- END IF
-
- PRINT
- LOOP UNTIL a>999
-
- PRINT "Would you like another game?"
-
- DO
- a$=UCASE$(INKEY$)
- LOOP UNTIL a$="Y" OR a$="N"
-
- IF a$="Y" THEN CALL game
-
- END SUB
-
- PRINT "Paul's number guessing game. "+CHR$(189)+" Copyright to Paul Jones and Atari Computing"
- PRINT "1997. Example program using SUB/FUNCTIONS and maths functions as in"
- PRINT "tutorial #3."
-
- CALL game
- STOP -1