Wave's~ BlitzMax Tutorial for NG | ~ November, 2015 ~ Version 11
Beginners guide to BlitzMax |
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)
Local A,B,C If a > 10 A = 10 Else If 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
Note: "End if" can also be written "EndIf", it does not matter which you use.
To Index | Next Page | page 4