tailbite knows NOTHING of your linkedlist because it was NOT declared INSIDE a procedure. when you call the procedure from your LIB and try to add an element after it is compiled, you are trying to add to a non-existent linkedlist. you must have a piece of code that executes the creation of the linkedlist at runtime in order to perform operations on it.
Code: Select all
Global VT.TB_GadgetVT
NewList TestList.s() ; POSSIBLY NOT ALLOWED IN A LIB ??? ;;;here is the problem
Procedure MyFreeGadget(GadgetID)
FreeGadget(GadgetID)
EndProcedure
ProcedureDLL CS_MyTestGadget(Gadget, x, y, width, height)
test = EditorGadget(Gadget,x,y,width,height)
AddElement(TestList()) ; CAUSES A CRASH DOWN OF THE PROGRAM
VT\FreeGadget = @MyFreeGadget()
TB_SetGadget(Gadget, GadgetID(test), @VT)
ProcedureReturn hWnd
EndProcedure
now if i may: a modified example
Code: Select all
Global VT.TB_GadgetVT
procedureDLL Init_your_lib();;;;now it WILL work
NewList TestList.s() ; IT's Allowed NOW
endprocedure
Procedure MyFreeGadget(GadgetID)
FreeGadget(GadgetID)
EndProcedure
ProcedureDLL CS_MyTestGadget(Gadget, x, y, width, height)
test = EditorGadget(Gadget,x,y,width,height)
AddElement(TestList()) ; WONT CRASH ANYMORE
VT\FreeGadget = @MyFreeGadget()
TB_SetGadget(Gadget, GadgetID(test), @VT)
ProcedureReturn hWnd
EndProcedure
i have created many a custom gadget where i use a linkedlist, and ALWAYS ALWAYS must you declare your linked list INSIDE a procedure, like an "Init_whatever()".
it really isnt a big deal that you have to call an "init" procedure. if people are going to complain about writing half a line of extra code, then they probably arent going to be using your LIB anyway.