Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple question - "Duplicate definition"
#1
This is the code for a simple guessing game, not all variable or labels are that helpfully names but it's so simple it's not hard to understand.
Code:
start: INPUT "Enter a number"; guess
number = INT(RND * 20 + 1)
s = 5
SLEEP
CLS
yyy: IF (guess > 20 OR guess < 0) THEN
PRINT "Your guess is more than 20 or less than zero. Enter another."
GOTO start
ELSEIF (guess > number) THEN
PRINT "You guessed larger than the number"
s -1
GOTO yyy
ELSEIF (guess < number) THEN
PRINT "You guessed a smaller number"
s -1
GOTO yyy
END IF

When I attempt to interpret this program the QBasic interpreter 1.1 highlights the first declaration (or possibly it's called an initialisation) of s, saying "Duplicate definition" which I do not understand, as I haven't defined s anywhere else, unless the statements lower down in which I attempt to decrement s have the incorrect syntax.

Any help would be appreciated and I expect you'll all know the answer very quickly Tongue
Reply


Messages In This Thread
Simple question - "Duplicate definition" - by HippyVanMan - 02-24-2007, 03:46 AM
Simple question - "Duplicate definition" - by Anonymous - 02-24-2007, 03:54 PM
Simple question - "Duplicate definition" - by Mac - 05-16-2007, 03:53 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)