List
 
     The List keyword is used in denote the addition of linked list support to a typed variable declaration.

eg.
  
  Dim MyVariable As MyType List
  





FACTS:


      * see LinkedLIsts tutorial




Mini Tutorial:



      This example uses the linked list mechanism to store a list of friend names. Before we can get the iterating through them, we first have to declare our tPerson type, define our Friends variable as a list then add some names to that list. Once that's done, it's just matter of using our For Each / Next controls to run and print them out.

  
  
; Declare the type tPerson with a single field called Name$
  Type tPerson
     Name$
  EndType
  
;  Dim the typed variable FRIENDS with added linked LIST support
  Dim Friends  As tPerson List
  
; Add a new Type to the head of the list
  Friends = New tPerson
; Init this  friends name
  Friends.Name$ = "Olivia"
  
;  Add another person to my friends list
  Friends = New tPerson
  
; Init this  friends name
  Friends.Name$ = "Tess"
  
  
;  Add another person to my friends list
  Friends = New tPerson
  
; Init this  friends name
  Friends.Name$ = "Jimbob"
  
  
  
; Run through and display my list of friends with FOR EACH
  For Each Friends()
     Print Friends.Name$
  Next
  
; Display the screen and wait for a key press.
  Sync
  WaitKey
  
  



Sample output.

  
  Jimbob
  Tess
  Olivia
  


 
Related Info: Continue | Dim | Do | Each | Exit | ExitFor | Loops | Next | Repeat | Step | Types | While :
 


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