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 / Basic programming questions

Author
Message
bulldozer777
12
Years of Service
User Offline
Joined: 1st May 2012
Location:
Posted: 8th May 2012 08:34
Hey guys I just have a couple basic programming questions. Brand new to this so if wouldn't mind giving me some help with them that would be great. Thanks.

1. How do I display string and numeric variables in specific locations on the screen?

2. How do you create and use accumulators?

3. What is the difference between a function and a sub routine. Can you give an example as well?

4. How do you write a For/Next loop and can it be displayed differently under different conditions?

5. How do you setup and use While/Endwhile, Repeat/Until, and Do/Loop repeat structures?
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 8th May 2012 15:44 Edited at: 11th May 2012 19:06
Quote: "1. How do I display string and numeric variables in specific locations on the screen?"

A couple of ways typically; you can set the cursor position by using SET CURSOR Xpos,Ypos or you can simply use the TEXT command.



Quote: "2. How do you create and use accumulators?"


The only accumulators I can think of are from my Assembly language days from years ago. Not sure what you mean here.

Quote: "3. What is the difference between a function and a sub routine. Can you give an example as well?"

Functions can return a value to the call and values can be passed to a function. Variables inside a function are considered local (i.e. the values are lost once you leave the function) and must be declared as global if you intend to use the changed value in the rest of the code. Example:



If you change the variable, WillNotShowUp, to global one, it will indeed show up. See here:



Subroutines will execute the code and return to where they were called. They do not return a value, but variables that are changed within a subroutine stay that way within the rest of the code. Subroutines need to have a label inserted in the code at their beginning (followed by a colon) and must have a RETURN statement at the end. Example:



Quote: "4. How do you write a For/Next loop and can it be displayed differently under different conditions?"


Examples:


Quote: "5. How do you setup and use While/Endwhile, Repeat/Until, and Do/Loop repeat structures? "


I have demonstrated all but the Do - Loop. I tend not to use it anymore, but here you go:



EDIT: Man, I hate it when I take the time to help a newbie, but then the newbie never shows up again or does not say whether or not the info helped them.

So many games to code.......so little time.

MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 8th May 2012 20:04
Or you can search the forum or buy the much handy HANDS ON DARKBASICPRO books from the store... Extremely handy!

Login to post a reply

Server time is: 2024-11-24 21:09:34
Your offset time is: 2024-11-24 21:09:34