Wave's~ BlitzMax Tutorial for NG ~ November, 2015 ~ Version 11
Beginners guide to BlitzMax 

Variables
You probably know this: A variable is a place where you may store a number or a text. There are different variable "types" depending on their use. Here are the most basic types: Integers which store numbers, Strings which store text and Floats which store decimal numbers.We also have object-"types" which includes these basic types such as Arrays, Lists and your own custom Types (more on these later). See the Language Reference if you want more information about BlitzMax variables.

If you want to increase a variable, let say speed. You can write Speed = Speed + Acceleration Or in a shorter way Speed:+Acceleration. Both are identical, but the last is shorter. You must declare your variables before use.

Local Speed: Float=0 , Acceleration:Int , Name:String = "Name"
Local Speed#= 0 , Acceleration , Name$ = "Name"
These 2 lines are identical; use whatever you like, but be aware of both.
Note:Local is a way to declare the variable.

Note: There are two levels of variable strictness in BlitzMax NG. The default assumes the command  Strict  which gives you a compile error if there is a variable that you didn't declare like this: Local/Global VarName:VarType , secondVarName:VarType, although any variable you declare with no type is assigned as an Int, and all functions/methods that do not declare a return type will also return Int. In  SuperStrict  mode you must declare everything with its type, including Int variables. A function/method without a return type cannot return anything.

Example:
Local Name$ = "-=[ Fireglue ]=-"
Whether you use Strict or SuperStrict is entirely up to you, and how lazy you are about declaring everything.

Note: BlitzMax considers Speed and speed and sPeEd to be the SAME variable.

Same goes with all commands.
Like rem or Rem or reM.
 
Global or Local
A variable can be Global or Local. Globals can be accessed from the entire program. Locals on the other hand are more complicated, because where they exists depends on where they where declared. This is called local scope. To declare a local variable use the keyword Local in front of the variable name. If you declare a local variable in a function it will only exist in that function. If it is declared in a loop if will only exists as long as you are in that loop. If a local is in an if-statement it will only exists in that if-statement.
 
Constants
You can also declare constants. A constant will have the value you gave it when you first declared it. The value of a Constant can never change, it will always stay the same. If you try to change a constant'a value the complier will warn you when you compile - build. Constant is useful for values that always will stay the same. You'll encounter constants in examples later on.
 
To Index | Next Pagepage 3