Functions are really useful. You can feed values into them and either get them to return values, or affect variables or objects.
They are constructed like this:
Function {function name(parameters, more parameters)}
maths expressions, or just any general code relating to the parameters
EndFunction {return value}
Start with a really simple function that returns a value. This will add two numbers together.
Function Add(x,y)
z=x+y
EndFunction z
This will take x and y, add them and put the result in z. z is returned from the function. To use this in a program, do this:
Sync On
a=4
Do
Rem We want to add 2 to a and print the result
Print Add(2,a)
Sync
Loop
Function Add(x,y)
z=x+y
EndFunction z
Now this is hardly the most useful function, but you can make your own functions for really complicated maths expressions you may have to do over and over, and functions that use several parameters.
You don't need to return a value, you can make functions which will affect objects or sprites in the game. For example:
Function strafe_object_left(object_number#,object_yangle#,dist#)
position object object_number object position x((object_number#)+(dist#*cos(object_yangle#-90))),object position y(object_number#),object position z(object_number#)+(dist#*sin(object_yangle#-90))
EndFunction
This moves an object based on it's current position, and so it doesn't need to return a value.
These aren't the most useful examples, but I hope they help you understand a bit.