Skip to main content
Version: 20 R7 BETA

Copy parameters

Copy parameters {( startFrom )} : Collection

ParameterTypeDescription
startFromIntegerStarting index (included)
Function resultCollectionNew collection containing parameters actually passed

Description

The Copy parameters command returns a new collection containing all parameters actually passed to a method or a function. This command is useful when you need to forward a various number of parameters from a method or function to another method or function.

In the startFrom optional parameter, you can pass the index of the parameter from which to start collecting parameters to forward. The startFrom parameter itself is included.

When called inside a formula, Copy parameters returns the parameters passed explicitely using apply() or call() (and not those passed to the parent method or function).

Copy parameters returns an empty collection if:

  • it is not called in a method or function that has been called by another method or function,
  • no parameter was passed to the parent method or function.

Example 1

Calling a different function depending on the first parameter and passing other parameters to this function:

 Function selectTask($task Text)
 Case of
    :($task="Task1")
       This.task1(Copy parameters(2))
    :($task="Task2")
       This.task2(Copy parameters(2))
 End case

Or, calling another function on another object with apply() and pass the parameters:

 Function doSomething($param Text;$extraParameters Variant)
 This.delegate.doSomething.apply(This.delegate;Copy parameters)

Example 2

Since the command returns a collection, it can be used with .join() to build for example a html list:

  // Class
 
 Function list($typeText)->Text
  //type of list is "u" or "o"
 var $value : Collection
 $value:=Copy parameters(2)
 $html:="<"+$type+"l>
* "
 $html+=$value.join("
* ")
 $html+="
"
 return$html
 
  // Method
 
 $htmlList:=$c.list("u";"Alpha";"Bravo";"Charlie")
  // $htmlList =
* Alpha
* Bravo
* Charlie

See also

Count parameters

Properties

Command number1790
Thread safe