Page 1 of 1
LikedList as Parameter
Posted: Sun May 07, 2006 3:16 am
by Konne
What am I doing wrong in this Code. (I'm trying to give a LisnkedList) to a procedure.
Code: Select all
Structure Request
Image.s
EndStructure
ProcedureDLL Requester(*Request.Request())
Debug AddElement(*Request())
Debug *Request()
CallFunctionFast(@Requester(),*Request())
CallDebugger
EndProcedure
NewList Request.Request()
Requester(@Request())
Posted: Sun May 07, 2006 6:58 am
by benny
@Konne:
I do not fully understand your source and what you intend to do with it

You call the procedure
Request recursively over and over again with
CallFunctionFast which will lead in a kind of zombie process.
Anyway if you want to call the procedure again in itself, I guess you would
have to pass a pointer on a pointer (**pRequest in C) as a parameter afaik - but
I am not quite sure if purebasic supports it and if I am right with this
statement :roll: .
Otherwise, you pass the linkedlist correctly imho:
Code: Select all
Structure Request
Image.s
EndStructure
ProcedureDLL Requester(*Request.Request())
Debug AddElement(*Request())
*Request()\Image = "Hello"
; Debug *Request()
;CallFunctionFast(@Requester(),*Request())
;CallDebugger
EndProcedure
NewList Request.Request()
Requester(@Request())
SelectElement(Request(), 0)
Debug Request()\Image
Nevertheless, I think it is now (PB V4.0) possible to simple pass a linked
list / array as a "normal" parameter:
See :
http://freak.purearea.net/v4/ReadMe.html#arrayparam
Posted: Sun May 07, 2006 11:56 am
by Kale
Your over complicating things:
Code: Select all
NewList Numbers.l()
AddElement(Numbers())
Numbers() = 25
AddElement(Numbers())
Numbers() = 50
AddElement(Numbers())
Numbers() = 75
Procedure EchoList(MyList.l())
ForEach MyList()
Debug MyList()
Next
EndProcedure
EchoList(Numbers())
Posted: Sun May 07, 2006 1:49 pm
by Konne
i know all this stuff but my problem is I need the recursion. Letzt explain my situation:
I have a dll with the funktion Request() this funktion has a LL as parameter. Now I have to call a funtion from an other dll, also with the same LL as Parameter. How can I do this without Memory Errors.
Posted: Sun May 07, 2006 6:05 pm
by benny
@Konne:
As I said, I think passing a pointer as a parameter in a recursion would require
the usage of a pointer on a pointer (symbolized as '**' in C e.g.). At least
in your case. [Although I am not 100% sure about this point - so anyone feel
free to correct me if I am wrong

]
Anyway, as the posted link says, PB4.0 now allows you to pass Linked Lists
and arrays as parameters, so why not use it

Maybe I still don't get your
point :roll:
Code: Select all
Structure Request
Image.s
EndStructure
Global t.l
t.l = 0
ProcedureDLL Requester(Request.Request())
Shared t.l
t + 1
Debug "Turn: " + Str(t)
AddElement(Request())
If t < 10
Requester(Request())
EndIf
;CallFunctionFast(@Requester(),Request())
;CallDebugger
EndProcedure
NewList Request.Request()
Requester(Request())
Debug Str(CountList(Request()))