ClearList()

语法

ClearList(List())
概要
Clears all the elements in this list and releases their memory. After this call the list is still usable, but the list is empty (i.e. there are no elements in it).

参数

List() The name of your list variable, created with the NewList function. You must include the brackets after the list name.

返回值

无.

Remarks

PureBasic will only free the memory for the elements. If you have been using the list for something such as storing handles of objects that you create directly with the OS, there is no way PureBasic (or any other language) can know what they are. Therefore, in cases such as that, you should go through the elements in the list and free the objects yourself.

示例

  NewList Numbers.w()

  ; A small loop to add many items to the list
  For i=1 To 100
    AddElement(Numbers())
    Numbers() = i
  Next

  ; Proof that items have been added to the list
  MessageRequester("Information", "There are "+Str(ListSize(Numbers()))+" elements in the list", #PB_MessageRequester_OK)
 
  ; Clear the list and show that the list really is empty
  ClearList(Numbers())
  MessageRequester("Information", "There are "+Str(ListSize(Numbers()))+" elements in the list", #PB_MessageRequester_OK)

参阅

DeleteElement(), FreeList()

已支持操作系统

所有

<- ChangeCurrentElement() - List Index - CopyList() ->