LIST.Create

Previous  Next

 

lid = LIST.Create( item_1-name  AS STRING,

                   item_1-type  AS TYPE,

                  [item_2-name  AS STRING,

                   item_2-type  AS TYPE,

                   .

                   .

                   item_n-name  AS STRING,

                   item_n-type  AS TYPE,]

                   initial-size AS INTEGER [=0] ) AS HANDLE

 


 

Creates a new List with the specified item types.  Each item can then be accessed by name or index (itx).  A List Element must have at least one Item.  Memory allocated for strings are freed when the list is deleted.  Any memory that has been allocated to a REFERENCE must be freed by the caller.  The function returns a handle to the List or LS_Fail

 

The Element Items can be of any of the following MyBASIC2 types:

 

INTEGER

REAL

STRING

REFERENCE

HANDLE

MODULE

 

Example:

 

DIM hList AS HANDLE

 

hList = LIST.Create( "Kalle", STRING, "Nisse", REAL, 4 )

 

LIST.At( hList, 0, 0, "Kalle Anka      " )

LIST.At( hList, 0, 1, 1.234 )

LIST.At( hList, 1, 0, "Kajsa Anka      " )

LIST.At( hList, 1, 1, 2.345 )

LIST.At( hList, 2, 0, "Joakim von Anka " )

LIST.At( hList, 2, 1, 3.456 )

LIST.At( hList, 3, 0, "Farmor Anka     " )

LIST.At( hList, 3, 1, 4.567 )