FirstElement()
Syntax
FirstElement(LinkedList())Description
Changes the current list element to the first list element.
Parameter:
LinkedList() - The name of your linked list variable, created with the NewList function. You must include the brackets after the list name.
Return value:
The value returned by this function can be used to show whether the first element exists or not (it will not exist if the list is empty). If the first item exists, this function will return a value which is not equal to zero. If the first element does not exist then it will return a value of zero.
Advanced users only:
The value that this function returns is a pointer to the first element data or zero if the first element does not exist.
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
Supported OS
All