This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com

Home

 
4D v20.6
Copy parameters

Copy parameters 


 

Copy parameters {( startFrom )} -> Function result 
Parameter Type   Description
startFrom  Longint in Starting index (included)
Function result  Collection in New collection containing parameters actually passed

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.

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)

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><li>"
 $html+=$value.join("</li><li>")
 $html+="</li></"+$type+"l>"
 return$html
 
  // Method
 
 $htmlList:=$c.list("u";"Alpha";"Bravo";"Charlie")
  // $htmlList = <ul><li>Alpha</li><li>Bravo</li><li>Charlie</li></ul>



See also 

Count parameters

 
PROPERTIES 

Product: 4D
Theme: Language
Number: 1790

This command can be run in preemptive processes

 
PAGE CONTENTS 
 
HISTORY 

Created: 4D v19 R5

 
ARTICLE USAGE

4D Language Reference ( 4D v20)
4D Language Reference ( 4D v20.1)
4D Language Reference ( 4D v20.2)
4D Language Reference ( 4D v20.3)
4D Language Reference ( 4D v20.4)
4D Language Reference ( 4D v20.5)
4D Language Reference ( 4D v20.6)