[Help] [Blitz] Functions
Author |
Message |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Sat Feb 21, 2004 10:41 am Post subject: [Help] [Blitz] Functions |
|
|
In Turing a function is like a procedure that has a result correct? (I never did funcs in class, and not much outside of class)
Functions in Blitz seem to be a bit different to me, though I'm really not too sure Anyways, could you write a quick tutorial on funcs in Blitz shorthair?
Much oblidged ![Smile Smile](images/smiles/icon_smile.gif) |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
shorthair
![](http://www.members.shaw.ca/rfolz/domo-kun.jpg)
|
Posted: Sat Feb 21, 2004 10:58 am Post subject: (No subject) |
|
|
Blitz Help ( if you dont get it , il write my own for you )
code: | Function {funcname}{typetag}( {params} )
{statements}
End Function |
{funcname}
is any valid identifier.
{typetag}
is the type of value returned by the function. If {typetag} is omitted, the function returns an integer value by default.
{params}
is a comma separated list of variables which is passed to the function when it is called, each parameter may be given an optional type tag. Parameters are always local.
A function may use the 'Return' statement to return a result. Just like turing , functions are very useful,
If there is no Return statement, or a Return without any expression is used, the function returns a default value of 0 for numeric functions, an empty string ("") for string functions, or a 'Null' object for custom type functions.
[/b] |
|
|
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Sat Feb 21, 2004 11:58 am Post subject: (No subject) |
|
|
K I'm kinda understanding these now.
code: |
Function larger (number1, number2)
If number1 > number2 Then
output = number1 + " is the largest number."
ElseIf number1 = number2 Then
output = number1 + " is equal to " + number2
Else
output = number2 + " is the largest number."
EndIf
End Function
Global num1, num2
Global output$
num1 = Input ("Enter first number ")
num2 = Input ("Enter second number ")
larger (num1, num2)
Print output
|
Do you have to have the function return something?
Is gosub the closest thing to procedure? |
|
|
|
|
![](images/spacer.gif) |
shorthair
![](http://www.members.shaw.ca/rfolz/domo-kun.jpg)
|
Posted: Sat Feb 21, 2004 12:13 pm Post subject: (No subject) |
|
|
if you dont need hte funtion to return somthing , then you shouldnt be using a function , you know like turing has procedures and functions , they both have their uses |
|
|
|
|
![](images/spacer.gif) |
|
|