DarkBasic Pro Tutorial: Basic Operators

James Cloud
Almost all games, applications or any type of programs makes use of programming operators and there is no exception when coding in DarkBasic Professional. There are several types or groups of operators, but this tutorial will only go over the most common types which are, mathematical, boolean and relational.

Boolean or Conditional Operators

Boolean type operators are perhaps the most common operator type in programming. The most basic Boolean operator can shown as:

IF bTest = 1 THEN bTest = 0

The above example will check to see if the Boolean "bTest" equals 1 and if it does will set the Boolean bTest to equal 0.

If you wish to execute more than one line of code when your Boolean condition is met make use of the ENDIF command as so:

IF bTest = 1 THEN

`Do some code here
`And here
`And here as well

ENDIF

You can also make use of the NOT, and the AND commands to add additional conditions to your Boolean expression.

Mathematical Operators

DarkBasic Pro has built in recognition for basic math functions which are:

- for subtraction.
+ for addition.
/ for division.
* for multiplication.
^ for powers.

Examples are:

8 + 8 = 16

X + B = X added to B

The same would apply to subtraction("-"), multiplication("*"), and division("/").

You can also use powers as a simplification of multiplication. For example, a simple way of 4*4*4, would be 4^3.

Relational or Another Type of Condition Operator

These relational operators are not as commonly used as the others operators discussed this article. However, game creators might find relational operators useful in certain cases and situations. Relational operators consist of Less Than or Equal To, Less Than, Greater Than, Greater or Equal To, Not Equal To and Equal To.

Less Than or Equal To is expressed as "" symbol.

Greater Than or Equal To is expressed as ">=".

Not Equal To can be expressed like "".

Equal To is expressed simply with "=" symbol.

Published by James Cloud

I like to program and do basically anything that has to do with technology and computers.  View profile

To comment, please sign in to your Yahoo! account, or sign up for a new account.