PDA

View Full Version : function_name



Lionheart008
18-11-2009, 18:17
help manual: function/subs / function_name

examples "function_name" and
"function_nparams" have the same code content. missing code for "function_name" ;)

"function_name" example:


'---Sum till 10 numbers using optional parameters

'---At least one number must be passed but even first parameter

'---can be declared as optional

uses "console"

FUNCTION MySum( _

N01 AS EXT , _

OPTIONAL _ '---From here all parameters will be considered optional

N02 AS EXT , _

N03 AS EXT , _

N04 AS EXT , _

N05 AS EXT , _

N06 AS EXT , _

N07 AS EXT , _

N08 AS EXT , _

N09 AS EXT , _

N10 AS EXT _

) AS EXT



FUNCTION = N01 + N02 + N03 + N04 + N05 + N06 + N07 + N08 + N09 + N10

MSGBOX 0, "Function has been declared to have " & FUNCTION_NParams & " parameters." & $CRLF & _

"This function has been called with " & FUNCTION_CParams & " parameters."



END FUNCTION



MSGBOX 0, "Sum: " & MySum(1,2)





frank

ErosOlmi
18-11-2009, 18:24
Thanks.

Example source code changed in order to have both keywords:


'---Sum till 10 numbers using optional parameters
'---At least one number must be passed but even first parameter
'---can be declared as optional
FUNCTION MySum( _
N01 AS EXT , _
OPTIONAL _ '---From here all parameters will be considered optional
N02 AS EXT , _
N03 AS EXT , _
N04 AS EXT , _
N05 AS EXT , _
N06 AS EXT , _
N07 AS EXT , _
N08 AS EXT , _
N09 AS EXT , _
N10 AS EXT _
) AS EXT

FUNCTION = N01 + N02 + N03 + N04 + N05 + N06 + N07 + N08 + N09 + N10
MSGBOX 0, _
"You are inside function " & FUNCTION_Name & $CRLF & _
"Function has been declared to have " & FUNCTION_NParams & " parameters." & $CRLF & _
"This function has been called with " & FUNCTION_CParams & " parameters."

END FUNCTION

MSGBOX 0, "Sum: " & MySum(1,2)