FirstElement()
Syntax
*Result = FirstElement(List())Description
Changes the current list element to the first list element.
Parameters
List() The name of your list variable, created with the NewList function. You must include the brackets after the list name.
Return value
Returns the address of the data in the first list element if successful and zero if there if there are no elements in the list.
Example
; An example of simple usage NewList Numbers.w() AddElement(Numbers()) Numbers() = 5 AddElement(Numbers()) Numbers() = 8 FirstElement(Numbers()) MessageRequester("Information", "First element value is "+Str(Numbers()), #PB_MessageRequester_OK) ; An example which uses the return-value NewList Numbers.w() If FirstElement(Numbers()) <> 0 MessageRequester("Information", "First element value is "+Str(Numbers()), #PB_MessageRequester_OK) Else MessageRequester("Information", "List is empty", #PB_MessageRequester_OK) EndIf AddElement(Numbers()) Numbers() = 5 AddElement(Numbers()) Numbers() = 8 If FirstElement(Numbers()) <> 0 MessageRequester("Information", "First element value is "+Str(Numbers()), #PB_MessageRequester_OK) Else MessageRequester("Information", "List is empty", #PB_MessageRequester_OK) EndIf ; An example which is only for advanced users NewList Numbers.w() AddElement(Numbers()) Numbers() = 5 AddElement(Numbers()) Numbers() = 8 *Element.Word = FirstElement(Numbers()) If *Element MessageRequester("Information", "First element value is "+Str(*Element\w), #PB_MessageRequester_OK) Else MessageRequester("Information", "List is empty", #PB_MessageRequester_OK) EndIf
See Also
LastElement(), PreviousElement(), NextElement(), SelectElement(), ListIndex()
Supported OS
All