Jump to content
  • Advertisement
Sign in to follow this  
eXtremeMachine

what is wrong

This topic is 4802 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

let a=0 let x=0 Print "game" Print "Press any key to continue" WHILE INKEY$ = "" X=RND() * 100 wend cls 1: input "What is the number"; a If x = a then print "yes, your number is"; a end if if x < a then print "Too high, your number is"; a goto 1 end if if x > a then print "Too high, your number is"; a goto 1 end if sleep theres the code, it is done in freebasic when i run it, it allways says "Too high, your number is and gives the number you put in" WHILE INKEY$ = "" X=RND() * 100 wend print x; sleep when i run that code it comes displays a different number each time why is the test command not working properly

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by eXtremeMachine
goto 1

I suggest the following: forget everything you know about "programming" and learn a proper language.

Share this post


Link to post
Share on other sites
whats is wrong with that i just want to try one language get above go the try another and so on. then decided where to go.

and whats is wrong with goto 1

Share this post


Link to post
Share on other sites
Goto makes baby jesus cry, kills your karma faster then anything else I know of, and it considered one of the worst things you can do. Goto littered code is one of the most unreadable things known to man (things intentionally made unreadable not taken into account), right up there with RSA encrypted documents and compressed video data. What you want to use are loops, not goto.

Share this post


Link to post
Share on other sites
Quote:
Original post by SirLuthor
Goto makes baby jesus cry, kills your karma faster then anything else I know of, and it considered one of the worst things you can do. Goto littered code is one of the most unreadable things known to man (things intentionally made unreadable not taken into account), right up there with RSA encrypted documents and compressed video data. What you want to use are loops, not goto.

There is nothing wrong with goto, especially in BASIC, and especially in very small apps like this one. Loop constructs in BASIC aren't too spectacular, and the code is perfectly readable as it is.

The real problem is this:
if x < a then
print "Too high, your number is"; a
goto 1
end if
if x > a then
print "Too high, your number is"; a
goto 1
end if
You have "Too high, your number is" in both if statements!

Share this post


Link to post
Share on other sites
Does it work correctly if you guess the number exactly?

One reason it might always be saying "Too high" is that you put the same message for the test cases of x < a and x > a. Try changing the print under x > a to "Too low".

Also, I think it would be easier (at least with the way you phrased your output) for people to read if you tested a = x, a < x, a > x since a is the variable that the user's guess is stored in.

Share this post


Link to post
Share on other sites
Quote:
Original post by Ra
There is nothing wrong with goto, especially in BASIC, and especially in very small apps like this one.


*nods*

While it's not a concept to base a large program around, they are often the easiest way to do something. And oftentimes in basic the only way to do it with any amount of elegance.

There is nothing wrong with learning BASIC. I wrote space invaders, arkanoid, pac man, and a 3D wireframe renderer in BASIC. The simple syntax gave me the start in programming that I needed. I still believe it to be one of the best learning languages around.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!