Page 1 of 1
How can I use a linked list as a parameter for a function?
Posted: Tue Aug 05, 2003 3:31 pm
by Dennis
Hello Everybody,
I have the problem, that I can not use a linked list as a parameter for a function?
What is the correct syntax/declaration for such a function??
Thx
Dennis
Posted: Tue Aug 05, 2003 4:03 pm
by Flype
all linkedlists are declared in global.
so you can access them inside procedures.
something like that :
Code: Select all
NewList test.s()
Procedure AddItem()
AddElement( test() )
test() = "new item"
EndProcedure
AddItem()
Debug test()
Posted: Tue Aug 05, 2003 4:29 pm
by venom
AddElement returns a pointer to the linkedlist with containing the next and previous pointers.
Code: Select all
Structure something
a.l
EndStructure
NewList abc.something()
AddElement(abc()) ; returns ptr to list of something
abc() ; returns a ptr to something (I believe its offset of the ptr above)
Posted: Wed Aug 06, 2003 8:17 am
by Dennis
my idea was something like that:
Structure something
a.l
EndStructure
function add (localist.something())
addElement(locallist())
endFunction
newList myList.something
add(myList())
This way did not work!
Posted: Wed Aug 06, 2003 10:31 am
by venom
I think you can only read the data from the ptrs, not treat them like a true PureBasic linkedlist.