The NewList command attaches a link structure to a type variable. It's the equivalent of dimensioning a type variable with the List keyword appended.
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 type variable Dim Friends As Person ; Add linked list support to our friends type NewList Friends() ; 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" ; Reset the List current index of this list ot the FIRST ; in the list ResetList Friends() ;Enter a while loop, but only while the current list position ; ifn't at the end of the list While Not EndOfList(Friends()) ; Display this persons name Print Friends.FirstName$+" "+Friends.Surname$ Print "" ; Move the current list pointer to the next link ; in the list. StepList Friends() EndWhile ; display the screen and wait for a key press Sync WaitKey |
This example would output. Olivia Dude Sally Stevens Billy Citizen |
|