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 / Im new to this and I would like some help please

Author
Message
Grmreepr
20
Years of Service
User Offline
Joined: 30th Dec 2003
Location: USA
Posted: 31st Dec 2003 23:49
Hi all! I finally got DarkBASIC pro yesterday! Well i started to learn the principles part of the manual, and to kinda go over what i learned so far, i started to make a simple text program. All was going good, i thought, until i tested it. I only finished the first subroutine to test it out, and the problem is at line 21. Can you please explain what i did wrong.(I posted the code) Im tryin to learn so bear with me
Also, once i grasp the principles and the tutorial in the manual, i plan on learning the binary moon tutorial and limit rush. Am i heading in the right track? Thanks a lot for the help
Grmreepr
20
Years of Service
User Offline
Joined: 30th Dec 2003
Location: USA
Posted: 31st Dec 2003 23:59
:- / For a second i thought i found out what the problem was, but i guess not. Well maybe it is a different problem i found later, but the first problem remains. What i thought i did wrong, was that i didnt label the actual subroutine "good" , so that the "gosub good" didnt know where to go, and then i thought maybe i should add the END command at the end of "IF letter$=a then gosub good". I'm not sure, can you explain the whole thing and all the problems in it? Just learnin Thanks a lot!
CarlTaylor
21
Years of Service
User Offline
Joined: 13th Jan 2003
Location: United States
Posted: 1st Jan 2004 00:53 Edited at: 1st Jan 2004 01:12
read my post below
sorry for taking up more space but theres no delete button!!

Don't leech graphics and code! Make your own or you'll never learn...
CarlTaylor
21
Years of Service
User Offline
Joined: 13th Jan 2003
Location: United States
Posted: 1st Jan 2004 01:11
Oh my god I posted three times and had to edit them all, my mind is just not with me today...lol

It's pretty good coding, only one tiny problem. When you wrote
Quote: "IF letter$=a then gosub good"
you were directing "letter$" to a variable named "a." There is no variable "a" because that would imply that "a" is a whole number. Your "a" is a string, so it should be changed to
Quote: "IF letter$=a$ then gosub good"


(If you finish this program and put in Subroutines B and C, remember to make those strings in that section of code as well.)

After you do that, you have to either slap a "Rem" on the front of
Quote: "If letter$="b" then gosub sad"
and
Quote: "If letter$="c" then gosub bored"
or just write "sad:" and "bored:" at the bottom of your source, because DBPro looks for all required labels before compiling.

Go back and try to do those things to your code. I have attached a working version of it with the changes I mentioned, but it would be much better for you to do yourself manually.

Happy new years

_Carl

Don't leech graphics and code! Make your own or you'll never learn...
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 1st Jan 2004 02:35
you can save yourself lines of code by changing

Input "What is your name?",name$
Print "Hello ";
Print name$;
Print "!"
Print " Press any key to continue."
Wait key

to

Input "What is your name?",name$
Print "Hello " ; name$ ; "!"
Print " Press any key to continue."
Wait key

use the ; as a string concatenation character

also regardless of what the dbp manual says you should strongly type your variables ahead of time, instead of relying on the silly $ or # characters. Note the use of hungarian notation below...

strName as String
intSomeValue as Integer
fltSomePreciseValue as Float

will make your code more readable in the long run, but I am not saying this is the only way to do things, just more intuitive this way IMHO
good luck

-RUST-

VB.NET makes me all goose-pimply! http://www.mod2software.com
Grmreepr
20
Years of Service
User Offline
Joined: 30th Dec 2003
Location: USA
Posted: 1st Jan 2004 04:57
Thanks Carl! Your post got me to understand what i did wrong, but after that we both left behind another mistake! I thinks

Instead of - IF letter$=a$ then gosub good
We should have - IF letter$="a" then gosub good

Because the computer would want the person to type in A$ which is
"I'm good. =A" My fix just asks the user to type in the letter "a" to tell the program that he's doing good, which would then go to the good: subroutine.
Ok, hang with me....
Now how do we make it so that what you type in doesnt have to be case sensitive? Otherwise the user must type in lowercase "a", but if he types in capital "A" the program quits.
I've tried - IF letter$="a"or"A" then gosub good - but that dont work.
I'll add cattlerustler's tips to the final version of my program, ill post it too!
Thank you all!
Happy new year!
Grmreepr
20
Years of Service
User Offline
Joined: 30th Dec 2003
Location: USA
Posted: 1st Jan 2004 23:48
Happy new year everyone!
I finished the little text program! For now i'll just use the $,#, instead of what cattlerustler said because i kinda like the symbols better, at least for now, but i did use cattlerrustler's way of printing (when applicable sp?)
--One question still remains, how do i make it so that what the user types in doesn't have to be case sensitive? otherwise when the user types in a,b,c, it HAS to be undercase.
Well, heres the finished (methinks) code!
By the way, can u tell me if im on the right track, and maybe what i should learn next? I meself am going to learn the rest of the principles first, but i would like to know what you think.
Thanks!

Login to post a reply

Server time is: 2024-09-21 13:33:10
Your offset time is: 2024-09-21 13:33:10