linked lists problem

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by richard.

hi,

this example doesn't work - why?

NewList TestList.BasicStructure()
AddElement(TestList())
*He = @TestList()
TestList()\Field2 = 1
AddElement(TestList())
TestList()\Field2 = 2
AddElement(TestList())
TestList()\Field2 = 3
;ChangeCurrentElement(TestList(), *He)
; MessageRequester("Number of elements in the list:", Str(TestList()\Field2), 0)
MessageRequester("Number of elements in the list:", Str(CountList(TestList())), 0)
ResetList(TestList()) ; Reset the list index before the first element.


what i would like to be able to do, is to use a pointer of a linked list in the function ResetList(TestList()) like ResetList(*He)

thanx for yout help

richard
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

In fact there is a little bug in the compiler about @LinkedListName(). Just use *He = LinkedListName() and it should work perfectly. Should be fixed in the next release.

Fred - AlphaSND
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by richard.

hi,

doesn't work

case 1:

NewList TestList.tableNode()
*He = TestList()
ResetList(*He)


case 2:

NewList TestList.tableNode()
*He = TestList()
ResetList(He)


thanx for your help

richard
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

Ho, I misunderstand your question. ResetList() like any other list function, need a linkedlist. It's not possible to use a pointer with it. The pointer can be only used with ChangeCurrentElement(). Why do you need to use a pointer inside ResetList() ?

Fred - AlphaSND
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by richard.

hi,
i want to create several lists and then use their pointers to work on them.

richard
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by richard.

rlp,

create for expl. 10 lists - save the pointers, which will be handed over to funtions to perform certain operations on them. such as pointer 4 (list 4) move to first - move to position 1500 and get the value (or user defined value).

remember the hash question?

regards

richard
Post Reply