home *** CD-ROM | disk | FTP | other *** search
/ Millennium Time Capsule / AC2000.BIN / disks / ac6_disk / tutorial.s / hbasic3.tut / numgame1.bas < prev    next >
Encoding:
BASIC Source File  |  1997-05-24  |  1.0 KB  |  61 lines

  1.  
  2. REM $option k10
  3. REM $option y+,v+,u+,[,]
  4.  
  5. DEF FNgen
  6. STATIC y
  7.  
  8. DO
  9. y=CINT(RND*1000)
  10. LOOP UNTIL y<1000 AND y>0
  11. FNgen=y
  12.  
  13. END DEF
  14.  
  15. SUB game
  16. STATIC num,low,high,turn,a,a$
  17.  
  18. RANDOMIZE
  19.  
  20. num=FNgen
  21.  
  22. turn=0
  23. low=1
  24. high=999
  25.  
  26. DO
  27. INCR turn
  28. PRINT "Turn:";turn
  29. PRINT "The number is between";low;"and";high
  30. PRINT
  31.  
  32. INPUT "What do you think the number is? ",a
  33.  
  34. IF a>999 THEN STOP
  35. IF a<num THEN PRINT "The number is greater than";a : IF a>low THEN low=a
  36. IF a>num THEN PRINT "The number is below";a : IF a<high THEN high=a
  37. IF a=num THEN
  38.     PRINT
  39.     PRINT "Congratulations! The number was";num;"and you guessed correctly in";turn;"turns!" : a=1000
  40.     PRINT
  41. END IF
  42.  
  43. PRINT 
  44. LOOP UNTIL a>999
  45.  
  46. PRINT "Would you like another game?"
  47.  
  48. DO
  49. a$=UCASE$(INKEY$)
  50. LOOP UNTIL a$="Y" OR a$="N"
  51.  
  52. IF a$="Y" THEN CALL game
  53.  
  54. END SUB
  55.  
  56. PRINT "Paul's number guessing game. "+CHR$(189)+" Copyright to Paul Jones and Atari Computing"
  57. PRINT "1997. Example program using SUB/FUNCTIONS and maths functions as in"
  58. PRINT "tutorial #3."
  59.  
  60. CALL game
  61. STOP -1