CopyList

List command

Syntax

Replaces the content of one list with a copy of another. Later changes to one list do not show in the other.

CopyList(<source>(), <destination>())

Parts

<source>The list to copy, with its parentheses. It is not changed.
<destination>The list that receives the copy, with its parentheses. Its old elements are lost.

Returns

1 when the copy was made, 0 when the two lists have different types (nothing is changed then).

Good to know

  • The copy is deep: record elements are copied field by field.
  • The destination gets the same current position as the source, and its PushListPosition() stack is emptied.
  • The types must match exactly. .i and .integer are the same type. Two record types with the same fields are not.
  • Writing b = a does not copy a list: both names then point to the same list.

Example

NewList a.integer()NewList b.integer()FOR k = 1 TO 3  AddElement(a())  a() = kNEXTConsole(Str(CopyList(a(), b())))   ' 1FirstElement(b())b() = 99FirstElement(a())Console(Str(a()) + " " + Str(ListSize(b())))   ' 1 3
In the manual : Arrays, lists and maps