Navigation:  thinBasic Modules > LL (Linked lists) >

LL_Add

Previous pageReturn to chapter overviewNext page

 

Description

 

Add a new item to a Linked List or create a new Linked List.

 

Syntax

 

Root = LL_Add(llRoot, ItemName, ItemData)

 

Returns

 

Number. A pointer to the root of the linked list

Root = 0 means error

 

Parameters

 

Name

Type

Optional

Meaning

llRoot

Number

No

If llRoot is = 0 (zero) a new linked list will be created and the new item added.

If llRoot is <> 0, a new item will be added to the linked list pointed by llRoot

ItemName

String

No

Name of the item. This is the key to be used to change, data in future reference

ItemData

String

No

Any string to be associated with ItemName

 

Remarks

 

To create a Linked List, pass 0 as llRoot. This will create a new List and return its pointer.

After the list is created, always pass its root to add new nodes.

 

Remember, it is responsibility of the programmer to deallocate memory used into a linked list using LL_Free when needed.

 

Restrictions

 

See also

 

LL_Free

 

Examples