ListAddItem

Top  Previous  Next

Prototype

 

intIndex=ListAddItem(IntHandle, strElement)

 

Description

 

Adds an element to the list

 

Parameters

 

IntHandle: integer value corresponding to the list handle

 

strElement: string corresponding to the element to add

 

Returned value

 

intIndex: integer value corresponding to the position of the element in the list

 

Notes

 

None.

 

Example

 

//It creates a new list

HandleList:=ListCreate; 

 

//It adds element to the list

ListAddItem(HandleList,'Element 1');

ListAddItem(HandleList,'Element 2');

ListAddItem(HandleList,'Element 3');

 

//It counts list element

TotalElements:=ListCount(HandleList);

ShowMessage('The element counted are: '+IntToStr(TotalElements));

 

//It finds element Index

IndexElements:=ListIndexOfItem(HandleList,'Element 2');

ShowMessage('Element 2 is in position '+IntToStr(IndexElements));

 

//It deletes an element

if (IndexElements>=0) and (IndexElements<TotalElements)

then ListDelete(HandleList,IndexElements);

 

//It destroys the list

ListDestroy(HandleList);