The GetListFirst() function retrieves the first position index from the queried linked list. if the list is empty then GetListFirst will return a -1
FACTS:
* Don't know what a linked list is ?, make sure you read the LinkedLists tutorial then.
Mini Tutorial:
This example creates a list of three people, then runs through the list manually and displays each persons names and their list position.
; Declare the "Person" user defined type. Type Person ; These Fields will hold this persons name FirstName$ SurName$ EndType ; Dimension the Friends variable of type Person, ; with linked list support Dim Friends As Person List ; Add a person (Billy) to Friends list Friends= New Person Friends.FirstName$ ="Billy" Friends.Surname$ ="Citizen" ; Add another person (Sally) to Friends list Friends= New Person Friends.FirstName$ ="Sally" Friends.Surname$ ="Stevens" ; Add another person (Sally) to Friends list Friends= New Person Friends.FirstName$ ="Olivia" Friends.Surname$ ="Dude" ; Aak the list what cell is at the front/start of the list ThisLInk=GetListFirst(Friends()) ;Enter a while loop providing the link is above 0 While ThisLink>0 ; Manually Set our Current position in the list SetListPos Friends(),ThisLInk ; Display this persons current position. Print "List Position="+Str$(GetListPos(Friends())) ; Display this persons name Print Friends.FirstName$+" "+Friends.Surname$ Print "" ; Ask the list for the Next LINK to move forward through ; the list. ThisLink=GetListNext(Friends()) EndWhile ; display the screen and wait for a key press Sync WaitKey |
This example would output. List Position=3 Olivia Dude List Position=2 Sally Stevens List Position=1 Billy Citizen |
|