NewList


Syntax
NewList name.<type>()      
Description
NewList allows to declare a new dynamic 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 List library.

The new list are always locals, which means 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 list as parameter to a procedure by using the keyword List.

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

Example: Simple list

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

Example: List as procedure parameter

  NewList Test()
  
  ; Adding the first 2 items to the list:
  AddElement(Test())
  Test() = 1
  AddElement(Test())
  Test() = 2
  
  Procedure DebugList(count, List ParameterList())
    ; Adding further items to the list:
    For i=1 To count
      AddElement(ParameterList())
      ParameterList() = i
    Next 
    
    ; Display all items in the list:
    i = 1
    ForEach ParameterList() 
      MessageRequester("List", "Entry" + Str(i) + " = " + Str(ParameterList()))
      i + 1
    Next
  EndProcedure
  
  ; Add another 3 items to the list and display the list contents:
  DebugList(3, Test())