Wave's~ BlitzMax Tutorial~ July 20, 2005 ~ Version 10
Beginners guide to BlitzMaxversion 7

Comments
Comments are text which explains the code. Comments are not required for your program to work, still it's one of those things you can't live without!
 
Here is a sample of a comment:
Local Speed# = 0 'Sets speed to zero
The ' denotes that the rest of that line will be a comment.
 
You can also use:
Rem
If you want to comment out several lines
End Rem
Comment much, it helps others who read your code and it will help you, because eventually you will forget why you did it a certain way or why you added that function and what it did. While you are new to programming I would advise you to comment almost every line. To explain something is a good way to learn it, use comments as your walking stick when you take your first steps in programming and blitzmax.

if-statements
If statements are used if you want to check if a condition has been met and then act upon that. This example does nothing special, it just shows you how to use if, else if, else and endif. (A,B,C and R are variables)
If a > 10
A = 10
ElseIf A < 0 and b => 2
R: - 10
Else
A:+B
End If
'Read: If A is greater than 10
'Read: Set A to 10
'Read: if A less than 0 and B is equal or greater than 2
'Read: Decrease R with 10. E.g. if R was 100 it is now 90
'Read: if none of above conditions is met do this
'Read: Add B to A. Or Increase A with B. That is: A = A + B

 

If you want to make the above example strict add these lines to the top of it:
Scrict
Local A,B,C

You can also write If statements on one line. The ; signals a new expression.
If A < 0 And C = 2 Then B = 2 ; C = 3 ; R:+5 Else A = 1 ; C:+1

The above line is equal to:
If A < 0 And C = 2
B = 2
C = 3
R:+5
Else
A = 1
C:+ 1
EndIf
Note: "End if" can also be written "EndIf", it does not matter which you use.
 
To Index | Next Pagepage 4