Function_CParams

<< Click to Display Table of Contents >>

Navigation:  ThinBASIC Core Language > Script structure > Functions/Subs >

Function_CParams

 

Description

 

If used inside a function, returns the number of parameters passed to the function.

 

Syntax

 

cParam = Function_CParams

 

Returns

 

Number.

 

Parameters

 

Name

Type

Optional

Meaning





 

Remarks

 

Restrictions

 

See also

 

Examples

 

'---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, "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)