Navigation:  thinBasic language > Script structure > Functions/Subs >

FUNCTION_CParams

Previous pageReturn to chapter overviewNext page

 

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)

 

 

© 2004-2008 thinBasic. All rights reserved. Version 1.6.0.7 Web Site: http://www.thinbasic.com