Post by Azan on Mar 13, 2005 16:35:49 GMT -5
Intro to Functions
In this tutorial you will learn how to ...
~ Create/call simple functions
Ok seeing as how this tutorial is really short I will show you our final product and explain it from there. (this is a modification of our old program that counts up to a certain number)
Global x=0
Global st=0
While st=0:
add()
printx()
stopx()
Wend
Function add()
x=x+1
End Function
Function printx()
Print x
End Function
Function stopx()
If x>1000 Then st=st+1
End Function
Ok first you will notice that x and st have global in front of them, this allows both of those variables to be called in functions (an example of globals would be life or experience), ok now lets skip down to
Function add()
x=x+1
End Function
function is how you start your function followed by its name "add" (you may name it what you want) followed by an open/close parenthesis (these are for parameters but we wont get into that now) then at the end of the function it is closed with end function.
Now you will notice that we have replaced our loop with this
While st=0:this is because we need to call up the function so now the program will run through each function and repeat it, (please note that in this case functions were really impractical but this was just an example, functions will be needed later when we get into graphics).
add()
printx()
stopx()
Wend
If you have any questions regarding what was discussed in this tutorial please post it in this thread.
Copyright: This document may not be posted anywhere else but ragnarokcom.proboards33.com with out the authors consent, by posting anywhere else with out the authors consent you are agreeing to give me your soul mwahahaha (but feel free to post links to this site/tutorial on other sites).