Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Ranomize Problem

Author
Message
cguy
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: In my Computer!
Posted: 8th Jul 2008 07:37
I am trying to make it so that one of the letters A, B, or C appear on the screen and it differs each time the program is run.

Only "A" ever apears on the screen! Any help?
pcRaider
17
Years of Service
User Offline
Joined: 30th May 2007
Location:
Posted: 8th Jul 2008 10:08
Try this
cguy
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: In my Computer!
Posted: 8th Jul 2008 10:15
wow...I think I tried everyhting except that! Thanks!
Moe
18
Years of Service
User Offline
Joined: 1st Apr 2006
Location: Sunny California
Posted: 8th Jul 2008 22:55
The variable on the left of the equal sign gets set to the variable on the right. So you were trying to set rnd(2) to x, whose default value was zero, so rnd(2) was getting set to zero, and x, staying at zero, made it so only A was printed.

parrot
cguy
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: In my Computer!
Posted: 9th Jul 2008 20:28
I created a program (idea from a tutorial by TDK) that generates a random number and a random range on which to pick it and lets you guess a the number.

The problem seems to be the same one as before! Only the default value zero is ever the random number. I don't think it's the same problem as before, because all the variables seem to be on the correct side of the equel sign.
cguy
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: In my Computer!
Posted: 9th Jul 2008 23:31
I changed it to "y", but it still stayed zero.
nackidno
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Där solen aldrig skiner
Posted: 9th Jul 2008 23:57 Edited at: 9th Jul 2008 23:59
Just a quick tip, though it has nothing to do with the issue you are having. Instead of this :

print "Your Name Here: ";
input name$


you can write this :

input$, "Your name here: ", name$

It's easier and spare you one line in your program.

- Elias, Damezean, Nackidno, Wonderboy

AntocGames - http://antocgames.se.nu/
cguy
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: In my Computer!
Posted: 10th Jul 2008 02:07
Just an update, my program does works sometimes, though it is no comfort
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 10th Jul 2008 03:27 Edited at: 10th Jul 2008 03:28
Quote: "You never assign any value to 'x'. It stays zero all the time."

^correct

Quote: "I changed it to "y", but it still stayed zero. "


The name of the variable wasn't the problem.

What is the number for the person to guess? It's "x", right? Well, what is "x" equal to? You need to set x equal to something. For example, x=5 would set x equal to 5. The number to guess would be 5. x=rnd(50) would set x equal to any number from 0 to 50, and the player would have to guess that number. Right now, because you never give "x" a value, it is equal to 0 because that is the default behavior for that type of variable.

Bottom line, write "x= (insert number here)" somewhere in your program before the player starts guessing!

Login to post a reply

Server time is: 2024-11-25 22:02:03
Your offset time is: 2024-11-25 22:02:03