GetListPrevious
CurrentPos = GetListPrevious(List())
 
Parameters:

    List() = The Type list handle you want to query
Returns:

    CurrentPos = The previous position index of this list
 

      The GetListPrevious() function retrieves the Previous position index (from the current index) from the queried linked list. If the current index is the first in the list, then GetListPrevious will return a -1. Since there's no item before the first item.




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 name
     Print Friends.FirstName$+" "+Friends.Surname$
     
   ; Display this index of back of the previous list item
     Print "Prev Position="+Str$(GetListPrevious(Friends()))
   ; Display this index of our current position within the list
     Print "List Position="+Str$(GetListPos(Friends()))
     
   ; Display this index of the next item in the list
     Print "Next Position="+Str$(GetListNext(Friends()))
     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.

  
  Olivia Dude
  Prev Position=-1
  List Position=3
  Next Position=2
  
  Sally Stevens
  Prev Position=3
  List Position=2
  Next Position=1
  
  Billy Citizen
  Prev Position=2
  List Position=1
  Next Position=-1
  
  

 
Related Info: Each | EndOfList | GetListFirst | GetListNext | GetListPos | GetListSize | LinkedLists | List | SetListPos | StepList :
 


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