SetListPos
SetListPos List(), CurrentPos
 
Parameters:

    List() = The Type list handle you wish to set
    CurrentPos = The Index to make the current position
Returns: NONE
 

      The SetListPos() function sets the current position index in the supplied linked list. The Index is screened for validity. If you provide and index that is no longer valid (was deleted for example) then SetListPos will ignore this request.





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
  
  

 
Related Info: Each | GetListFirst | GetListNext | GetListPos | GetListPrevious | LinkedLists | List :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com