Page 1 of 1
Prototype with LinkedList
Posted: Wed Oct 03, 2007 3:40 pm
by Leonhard
Why can I not use LinkedList with prototypes?
I have build a example:
Code: Select all
Prototype.l Callback(nValue.l)
Global NewList e_Event_Call.Callback()
Procedure Event1(nValue.l)
Debug "CALL-1: "+Str(nValue)
EndProcedure
Procedure Event2(nValue.l)
Debug "CALL-2: "+Str(nValue)
EndProcedure
Procedure Event3(nValue.l)
Debug "CALL-3: "+Str(nValue)
EndProcedure
AddElement(e_Event_Call()) : e_Event_Call() = @Event1()
AddElement(e_Event_Call()) : e_Event_Call() = @Event2()
AddElement(e_Event_Call()) : e_Event_Call() = @Event3()
Debug e_Event_Call()(43)
Debug e_Event_Call()(534)
Debug e_Event_Call()(955)
Posted: Wed Oct 03, 2007 4:10 pm
by Fred
The syntax is ugly

Posted: Thu Oct 04, 2007 1:15 pm
by Leonhard
other ideas?
Posted: Thu Oct 04, 2007 4:27 pm
by Dr. Dri
Fred wrote:The syntax is ugly

the linkedlist syntax itself is ugly

the same goes for arrays
Dri
Posted: Thu Oct 04, 2007 5:16 pm
by DoubleDutch
huh, whats ugly about the linkedlist and array syntax?
Posted: Thu Oct 04, 2007 6:25 pm
by freak
Leonhard wrote:other ideas?
Just use a structure...
Code: Select all
Prototype.l Callback(nValue.l)
Structure CallbackStruct
Call.Callback
EndStructure
Global NewList e_Event_Call.CallbackStruct()
Procedure Event1(nValue.l)
Debug "CALL-1: "+Str(nValue)
EndProcedure
Procedure Event2(nValue.l)
Debug "CALL-2: "+Str(nValue)
EndProcedure
Procedure Event3(nValue.l)
Debug "CALL-3: "+Str(nValue)
EndProcedure
AddElement(e_Event_Call()) : e_Event_Call()\Call = @Event1()
AddElement(e_Event_Call()) : e_Event_Call()\Call = @Event2()
AddElement(e_Event_Call()) : e_Event_Call()\Call = @Event3()
Debug e_Event_Call()\Call(43)
Debug e_Event_Call()\Call(534)
Debug e_Event_Call()\Call(955)
Posted: Thu Oct 04, 2007 7:40 pm
by IceSoft
freak wrote:Leonhard wrote:other ideas?
Just use a structure...
Code: Select all
Prototype.l Callback(nValue.l)
Structure CallbackStruct
Call.Callback
EndStructure
Global NewList e_Event_Call.CallbackStruct()
Procedure Event1(nValue.l)
Debug "CALL-1: "+Str(nValue)
EndProcedure
Procedure Event2(nValue.l)
Debug "CALL-2: "+Str(nValue)
EndProcedure
Procedure Event3(nValue.l)
Debug "CALL-3: "+Str(nValue)
EndProcedure
AddElement(e_Event_Call()) : e_Event_Call()\Call = @Event1()
AddElement(e_Event_Call()) : e_Event_Call()\Call = @Event2()
AddElement(e_Event_Call()) : e_Event_Call()\Call = @Event3()
Debug e_Event_Call()\Call(43)
Debug e_Event_Call()\Call(534)
Debug e_Event_Call()\Call(955)
Hippiaiho!
@freak,
You use OOP ideas. Shame on you
Please remove:
Code: Select all
Debug e_Event_Call()\Call(43)
Debug e_Event_Call()\Call(534)
Debug e_Event_Call()\Call(955)
with:
Code: Select all
ForEach e_Event_Call()
Debug e_Event_Call()\Call(534)
Next
Posted: Thu Oct 04, 2007 9:31 pm
by Psychophanta
Posted: Thu Oct 04, 2007 9:40 pm
by Dr. Dri
DoubleDutch wrote:huh, whats ugly about the linkedlist and array syntax?
i can't have an array of lists, or a list of arrays etc...
Dri
Posted: Thu Oct 04, 2007 11:47 pm
by DoubleDutch
Those would be useful I agree.