SwapElements()

语法

SwapElements(List(), *FirstElement, *SecondElement)
概要
Swaps the position of two elements in the specified list. This command is a fast way to reorganize a list, because it does not actually move the element data itself.

参数

List() The name of your list variable, created with the NewList function. You must include the brackets after the list name.
*FirstElement Address of the first element to swap. You can get this address by using the @ operator on the list name.
*SecondElement Address of the second element to swap. You can get this address by using the @ operator on the list name.

返回值

无.

示例

  NewList Numbers()
  
  For k=0 To 10
    AddElement(Numbers())
    Numbers() = k
  Next
    
  SelectElement(Numbers(), 3) ; Get the 4th element (first element is 0)
  *FirstElement = @Numbers()
  
  SelectElement(Numbers(), 9) ; Get the 10th element
  *SecondElement = @Numbers()
  
  ; Swap the 3 with the 9
  ;
  SwapElements(Numbers(), *FirstElement, *SecondElement)
    
  ; Prove it
  ;
  ForEach Numbers()
    Debug Numbers()
  Next

参阅

MoveElement()

已支持操作系统

所有

<- SplitList() - List Index