NewList


Syntax
NewList name.<type>()      
Description
NewList allows to declare a new dynamic linked-list. Each element of the list is allocated dynamically. There are no element limits, so there can be as many as needed. A list can have any Variables standard or structured type. To view all commands used to manage lists, see the LinkedList library.

The new linked-list are always locals, which means than Global or Shared commands have to be used if a list declared in the main source need to be used in procedures. It is also possible to pass a linked-list as parameter to a procedure by using the keyword List.

For fast swapping of linked-list contents the Swap keyword is available.

Example: Simple list

  NewList MyList.l()
  
  AddElement(MyList())
  MyList() = 10
  
  AddElement(MyList())
  MyList() = 20
  
  AddElement(MyList())
  MyList() = 30
  
  ForEach MyList()
    Debug MyList()
  Next

Example: List as procedure parameter

  NewList Test.l()

  AddElement(Test())
  Test() = 1
  AddElement(Test())
  Test() = 2

  Procedure DebugList(c.l, List ParameterList.l())

    AddElement(ParameterList())
    ParameterList() = 3

    ForEach ParameterList()
      MessageRequester("List", Str(ParameterList()))
    Next
 
  EndProcedure

  DebugList(10, Test())