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 / Help with If...Else...Endif branching statement!!!

Author
Message
Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 18th Sep 2005 21:12
I am trying to write a program that determines the number between 1 and 63 that you are thinking of. It shows you a group of numbers and you are to press either 'y' or 'n' corresponding to whether or not your number is in that group of numbers. If 'y' is entered, then the first number in the group is added to the total, if 'n' is entered, then 0 or nothing is added to the total. At the end, all the numbers are to be summed up and the number the user was thinking of is printed to the screen. I was trying to write it with first using just the bare commands first so I can see how things work basically, then shorten the code up using loops and what not.

The problem is, it seems that DarkBASIC Pro is understanding that the user is answering 'y' to all of the questions and in which case, 63 will be the number the user is thinking of. No matter what is entered by the user, 63 is always the answer. It seems that the If...Else...Endif branching statements are jacked up. I don't know what is going on.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 19th Sep 2005 02:39
Try clicking on the little source button bottom right of your post to see the code you pasted...

TDK_Man

Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 19th Sep 2005 03:46 Edited at: 19th Sep 2005 04:42


(code tags added by Moderator)
Me!
19
Years of Service
User Offline
Joined: 26th Jul 2005
Location:
Posted: 19th Sep 2005 10:56 Edited at: 19th Sep 2005 10:57
put simply you need to read up on variable types, you can not put the character "A" into the variable a, a would be an integer, you need to store characters in strings, so your line should read

input a$


and your comparison would read

if a$="y"

you are trying to treat them as numbers, so it simply will not work.



the average IQ is 100...but the people that took the test where trying to look smart. most people don`t go over 50.
Area 51?, I`m more intrested in what they have in areas 1 to 50

Login to post a reply

Server time is: 2024-09-24 05:25:53
Your offset time is: 2024-09-24 05:25:53