ListIndex()
语法
Index = ListIndex(List())概要
Find out the position of the current element in the list, considering that the first element is at the position 0. This function is very fast, and can be used a lot without performance issue (it doesn't iterate the list but uses a cached value).
参数
List() The name of your list variable, created with the NewList function. You must include the brackets after the list name.
返回值
A number containing the position of the current element within the list. The first element is at position 0, the next at 1 and so on. A value of -1 means there is no current element (either the list is empty or ResetList() has been used).
示例
NewList fruit.s() AddElement(fruit()) : fruit() = "oranges" AddElement(fruit()) : fruit() = "bananas" AddElement(fruit()) : fruit() = "apples" AddElement(fruit()) : fruit() = "pears" FirstElement(fruit()) MessageRequester("Fruit: "+fruit(), "Now at position "+Str(ListIndex(fruit())), #PB_MessageRequester_OK) NextElement(fruit()) MessageRequester("Fruit: "+fruit(), "Now at position "+Str(ListIndex(fruit())), #PB_MessageRequester_OK) NextElement(fruit()) MessageRequester("Fruit: "+fruit(), "Now at position "+Str(ListIndex(fruit())), #PB_MessageRequester_OK) NextElement(fruit()) MessageRequester("Fruit: "+fruit(), "Now at position "+Str(ListIndex(fruit())), #PB_MessageRequester_OK)
参阅
SelectElement(), ListSize()
已支持操作系统
所有