Page 1 of 1
A bug in TailBite?
Posted: Fri May 27, 2005 3:58 pm
by CSAUER
Hi all,
possibly a bug in TailBite or generally not possible within a userlib:
AddElement() ???
When I generating a Gadget (according to following code) and try to use it in a program, the program crashes.
Code: Select all
Global VT.TB_GadgetVT
NewList TestList.s() ; POSSIBLY NOT ALLOWED IN A LIB ???
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
Is this a bug or not allowed?
Best Regards
Christian
Posted: Fri May 27, 2005 5:00 pm
by localmotion34
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.
Posted: Sat May 28, 2005 1:48 am
by El_Choni
Just to say the initialization function must be named "whatever_Init", NOT "Init_whatever".
Regards,
Posted: Sat May 28, 2005 3:09 am
by localmotion34
@ Elchoni
and why might that be? i use functions like InitDUI() for my directUIHwnd and other custom gadgets. never had a problem there. can you explain please, as i might be severely missing something?
Posted: Sat May 28, 2005 4:45 am
by Paul
Because whatever is in the the Name_Init() procedure is auto initialized the first time any function from the library is called... so there is no need to specifically call any Init function first from your app to make things work.
Cool eh?!
(by the way, this info is in the TailBite help file)
Posted: Sun May 29, 2005 12:00 pm
by CSAUER
Thanks for your support and your explanation.
I figured out another mysterial thing:
When I use a string with a colon inside, the TailBite compiler breaks.
I had this problem, when I used a DataSection:
Code: Select all
DataSection
TestData:
Data.s "(",")","+","-","/","*",":",";","[","]","!=",">","<"
EndDataSection
I will get a TailBite error message like this:
FAsm: CS_CodeGadgetShared.asm
flat assembler version 1.58
[filepath]
Public.db "(",0,")",0,"+",0,"-",0,"/",0,"*",0,"
error: missing end quote.
The Pipe has been ended.
Do you have any idea, what can I do to use a ":" string?
Thanks a lot in advance.
Best Regards
Christian
Posted: Sun May 29, 2005 12:28 pm
by Num3
Just an idea ...
Instead of saving the characthers, save their ascii value:
Asc("[") = 91
