Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 [Help] [Blitz] Functions
Index -> Programming, Visual Basic and Other Basics -> Other Basics
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Cervantes




PostPosted: 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 Confused Anyways, could you write a quick tutorial on funcs in Blitz shorthair?
Much oblidged Smile
Sponsor
Sponsor
Sponsor
sponsor
shorthair




PostPosted: 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]
Cervantes




PostPosted: 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?
shorthair




PostPosted: 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
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Other Basics
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: