Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Excerpt
hiddentrue

subList([[value1, value2, value3, ...]], <startPosition>) Returns a portion of the supplied List.

Attribute Function: subList

Returns a portion of the supplied List.

Syntax

...

Script

The following script extracts a set of values from a list or array of values, to create a sublist.

Code Block
do(
  $list = $args[1],
  $startPosition = $args[2],
  $endPosition = $args[3],
  $subList = [],

  forEach($i,$startPosition..$endPosition,
    $subList = addElement($subList, getElement($list,$i)),
    _NULL
  ),

  $subList
)

Using the Script as a Macro

Save this script into a macro named subList.

Set Minimum Parameters and Maximum Parameters to 3.

Image Added

In an expression, use the following syntax to run the subList macro in order to return a sub-list extracted from the supplied list. 

Syntax

Code Block
subList([value1, value2, value3,...], <startPosition>, <endPosition>)

 


ArgumentType
valuenA value of any type
startPositionInteger
endPositionInteger

Usage

subList([value1, value2, value3,...], <startPosition>, <endPosition>)

Returns a list, drawn from the given list, starting at element position <startPosition>, and ending at element position <endPosition>.

subList([value1, value2, value3,...], <startPosition>)

Returns a list, drawn from the given list, starting at element position <startPosition>, and ending at the end of <List>.

...

representing where to start extracting values.Cannot be zero or a negative number.
endPositionInteger representing where to stop extracting values. 

Example

Code Block
subList([1,2,3,4,5,6,7,8,9,10],6,9) 

returns the portion of the supplied List between element positions 6 and 9: [6,7,8,9

...

]

...