functions built into DarkBASIC Pro such as math functions, input functions and many more. You can even make your own functions in DarkBASIC Pro.
An example of a math function in DarkBASIC Pro is the "ABS" function. This function simple converts a negative number or integer into a positive.
Example:
MyNumber = ABS(-25)
MyNumber will return a positive 25.
You can, of course, use regular mathematical expressions in DarkBASIC Professional, such as adding, subtracting, division, multiplication, and more
advanced mathematical expressions.
Example:
Math = A + B / C * A - 20
You can use functions in the same way and in the same places as you would use a string or a variable as long as the function returns the corresponding
value.
The "GET DIR$" function will return the string value of the current working directory, or the directory where your game is located.
You can retrieve the Windows directory or the My Documents Directory by using the "WINDIR$" and "MYDOCDIR$" functions.
There many other built in functions that come with DarkBASIC Professional to learn what these are read your DarkBASIC Manual or help file found under Help menu in the DarkBASIC Pro IDE.
User Created Functions in DarkBASIC Professional
All professional coders use functions to increase the reliability and usability of their code. Therefore it is vital that you learn how to incorporate your own custom functions into your DarkBASIC Pro game or application.
You should create a function when you want to use a large set of code over in over again throughout your application.
For example, if I wanted to execute 10 lines of code throughout my game instead of rewriting these 10 lines over and over again I could just put them into a function and then just execute that functions name when ever I wanted to use the code. This would cut 10 lines of code down to 1 simple line.
To make a custom function simply enclose your desired code in the "FUNCTION" and "ENDFUNCTION" tags. You will also need to give a name to your function.
Example:
FUNCTION DivideNumber(Number, BY)
Number = Number / BY
ENDFUNCTION Number
The above code will divide the number supplied in the first parameter by the number given in the second and return the results.
Published by James Cloud
I like to program and do basically anything that has to do with technology and computers. View profile
How to Do Lens and Perspective Correction in Paint Shop ProSometimes pictures come out with lens and perspective distortion, and distracting background elements. If your item is square
or rectangular, such as a painting or print, t...- The Pro-Choice ArgumentDespite the surprising number of pro-life people out there, I have always considered myself pro-choice. A baby should be a woman's choice.
When Home Improvements Should Be Left to a ProfessionalMany projects that seem like a do it yourself kind of job actually require a professional. Here are some tips on do it yourself home improvements and when you should seek profe...- How to Hire a Professional Belly DancerMany things go into the cost of the performance. The professional Belly Dancer has had a lifetime of dance classes, costume expenses, and may charge for traveling time.
- The Differences Between Puppy Mills and Professional KennelsThere are many differences between puppy mills and professional kennels: here is what you should know about both, and how to make sure you don't inadvertently support puppy mills
- 10 Tips to Make Your Home Based Business Look Professional
- Accounting Continuing Professional Education
- The Disgraceful State of Professional Sports
- How to Give Your Home Business a Professional Image
- How to Write for a Professional Magazine
- Presidential Hopeful Mitt Romney and His Pro-Life Waffle
- Professional Make-Up Tips



