Guess It in Runbasic
' Guess what number for RunBASIC
' E.K.virtanen. 2007, public domain

' Made because of this;

' min & max variable values
constMin = 1
constMax = 100

' main loop of program
    rounds = 1
    randomed = int(rnd(1)*constMax) + constMin

    print "Ok, i think a random number between "; constMin; " and "; constMax; "."
    print "Your job is to guess what it is, in as minimal tries as possible."
    print "After your every guess, ill give you hint is my number higher or lower than your guess."
    Print "You can exit by 'guessing' 0."

        ' From here starts the gaming loop itself. This is looped until guess it right one.

        print "This is round number:"; rounds
        input "OK.  What is your guess?"; guess
        let rounds = rounds + 1

        ' if player wants to quit
        if guess = 0 then goto [yesno]

        ' error check
        if guess < constMin or guess > constMax + constMin then
            print "Error input: No rounds counted."
            let rounds = rounds - 1
        end if

        ' check if guess was correct, lower, higher or does player want to end game
        if guess = randomed then goto [correct]
        if guess < randomed then print "My number is higher."
        if guess > randomed then print "My number is lower."

        goto [game]

        ' If player wants to quit, we confirm it with this "sub"
        input "Want to quit? Press '0' to confirm."; guess
        if guess = 0 then end
        goto [game]

        ' Player got correct number. We celebrate it a bit.
        print "You got it!!!"
        print "It took "; rounds; " rounds to guess right number."
        print ""

        input "Press 'y' to play again. Any other key to quit."; playmore$
        if instr("yY", playmore$) > 0 then goto [program]
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.