sandyrepope
23-02-2007, 22:56
I don't know if this is the right place for this so someone please let me know if it isn't.
This is my script that plays the number guessing game:
uses "console"
dim Quit as long
dim myNum as string
dim guess as string
dim Playing as long
dim Play_again as long
dim Result as string
dim n as long
dim Num_check as long
dim Num_only as long
dim Player_guess as long
Intro()
Quit = %false
while Quit = %False
randomize
myNum = int(rnd(1,100))
console_writeline("I've picked a number")
console_writeline("")
Playing = %false
while Playing = %false
Num_only = %false
while Num_only = %false
console_write("What is your guess? ")
guess = int(console_readline())
Num_check = VERIFY(guess, "0123456789")
select case Num_check
case <> 0
console_writeline("Your guess MUST be a whole number!")
console_writeline("")
case else
N = between(guess,1,99)
if N <> 0 then
Num_only = %true
else
console_writeline("Your guess is out of range!")
console_writeline("Try again")
console_writeline("")
end if
end select
wend
if guess < myNum then
console_writeline("Your guess is too low!")
console_writeline("")
end if
if guess > myNum then
console_writeline("Your guess is too high!")
console_writeline("")
end if
if guess = myNum then
console_writeline("CONGRADULATIONS!!! YOU WON!")
console_writeline("")
Playing = %true
end if
wend
console_write("Play again? ( (Y)es or (N)o )")
Play_again = %false
WHILE Play_again = %FALSE
'---Read keyboard input
Result = Console_inKeyb
'---Handle returned string
select case Result
case "n","N"
Console_Writeline("")
console_writeline("GOODBYE!!!")
n = sleep(1000)
Play_again = %TRUE
Quit = %true
case "y","Y"
Console_writeline("")
console_writeline("")
Play_again = %true
end select
wend
wend
function Intro()
console_writeline("A Guessing Game!")
console_writeline("")
console_writeline("I will choose a number between 1 and 100.")
console_writeline("You will try to guess the number. Whole numbers only.")
Console_writeline("If your guess is higher than my number, I'll say 'too high'")
console_writeline("If your guess is lower than my number, I'll say 'too low'")
console_writeline("When you have guessed the number, you win")
console_writeline("")
end function
If someone finds something wrong with this script Please let me know about it.
Thanks
This is my script that plays the number guessing game:
uses "console"
dim Quit as long
dim myNum as string
dim guess as string
dim Playing as long
dim Play_again as long
dim Result as string
dim n as long
dim Num_check as long
dim Num_only as long
dim Player_guess as long
Intro()
Quit = %false
while Quit = %False
randomize
myNum = int(rnd(1,100))
console_writeline("I've picked a number")
console_writeline("")
Playing = %false
while Playing = %false
Num_only = %false
while Num_only = %false
console_write("What is your guess? ")
guess = int(console_readline())
Num_check = VERIFY(guess, "0123456789")
select case Num_check
case <> 0
console_writeline("Your guess MUST be a whole number!")
console_writeline("")
case else
N = between(guess,1,99)
if N <> 0 then
Num_only = %true
else
console_writeline("Your guess is out of range!")
console_writeline("Try again")
console_writeline("")
end if
end select
wend
if guess < myNum then
console_writeline("Your guess is too low!")
console_writeline("")
end if
if guess > myNum then
console_writeline("Your guess is too high!")
console_writeline("")
end if
if guess = myNum then
console_writeline("CONGRADULATIONS!!! YOU WON!")
console_writeline("")
Playing = %true
end if
wend
console_write("Play again? ( (Y)es or (N)o )")
Play_again = %false
WHILE Play_again = %FALSE
'---Read keyboard input
Result = Console_inKeyb
'---Handle returned string
select case Result
case "n","N"
Console_Writeline("")
console_writeline("GOODBYE!!!")
n = sleep(1000)
Play_again = %TRUE
Quit = %true
case "y","Y"
Console_writeline("")
console_writeline("")
Play_again = %true
end select
wend
wend
function Intro()
console_writeline("A Guessing Game!")
console_writeline("")
console_writeline("I will choose a number between 1 and 100.")
console_writeline("You will try to guess the number. Whole numbers only.")
Console_writeline("If your guess is higher than my number, I'll say 'too high'")
console_writeline("If your guess is lower than my number, I'll say 'too low'")
console_writeline("When you have guessed the number, you win")
console_writeline("")
end function
If someone finds something wrong with this script Please let me know about it.
Thanks