A bug in TailBite?

Everything else that doesn't fall into one of the other PB categories.
CSAUER
Enthusiast
Enthusiast
Posts: 188
Joined: Mon Oct 18, 2004 7:23 am
Location: Germany

A bug in TailBite?

Post 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
localmotion34
Enthusiast
Enthusiast
Posts: 665
Joined: Fri Sep 12, 2003 10:40 pm
Location: Tallahassee, Florida

Post 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.

Code: Select all

!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post by El_Choni »

Just to say the initialization function must be named "whatever_Init", NOT "Init_whatever".

Regards,
El_Choni
localmotion34
Enthusiast
Enthusiast
Posts: 665
Joined: Fri Sep 12, 2003 10:40 pm
Location: Tallahassee, Florida

Post 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?

Code: Select all

!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1285
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post 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)
CSAUER
Enthusiast
Enthusiast
Posts: 188
Joined: Mon Oct 18, 2004 7:23 am
Location: Germany

Post 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
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Just an idea ...

Instead of saving the characthers, save their ascii value:

Asc("[") = 91

:P
Post Reply