PARAMS (specify variable method parameters)

Top  Previous  Next

 

PARAMS array arrayname

 

PARAMS

Specify variable method parameters

array

An arrayed data type (i.e., LONG[ ])

arrayname

Label of the array referenced in the method source.

 

PARAMS lets you specify a method parameter that takes an argument where the number of arguments is variable. PARAMS does not have a pre defined size.

 

PARAMS parameters is a very useful feature in Clarion#. They are used when a variable number of arguments need to be passed. PARAMS should be a single dimensional array.

 

The value passed for a PARAMS parameter can be either a comma separated value list or a single dimensional array. These parameters are input only.

 

PARAMS parameters must also be the last parameter in the prototype, and only one PARAMS keyword is permitted in a procedure declaration/definition. To force at least one parameter to be passed you can define something like this:

 

NodeFill     procedure(LONG firstParameter ,Params LONG[] parColors)

!This prototype requires at least one LONG

 

 

Examples:

 

!Calculate the sum of parameters

TOTAL PROCEDURE(PARAMS *LONG [] VARARG), LONG

TTL  LONG

 

CODE

TTL=0

LOOP X# = 1 TO MAXIMUM(VARARG,1)

 TTL+=VARARG[X#]

END

RETURN TTL

 

TEST  PROCEDURE()

RES   LONG

CODE

RES=TOTAL(1,2,3) ! Now RES=1+2+3=6

 

GraphTextClass class,type,module('SVGraph.clw'),link('SVGraph.clw',_ABCLinkMode_),dll(_ABCDllMode_)

SetBgr          procedure(PARAMS LONG[] parColors), virtual

SetBorder       procedure(long parColor=color:none), virtual

SetAlignment    procedure(long parValue), virtual

SetAngle        procedure(real parAngle), virtual

SetRectangle    procedure(<real parX>, <real parY>, <real parW>, <real parH>), virtual

Calculate       procedure, virtual

!

Draw            procedure, virtual

              End

*****

 CODE

SetBgr(1,2,3) !or SerBgr(1,2,3,4,5,6,7) or SetBgr(MyLongArray)