Page 38 of 40

Posted: Mon Jul 09, 2007 2:12 pm
by Progi1984
Small question : how are managed protoypes with tailbite ?

Posted: Mon Jul 09, 2007 3:02 pm
by ABBKlaus
same restrictions as ProcedureDLL, no optional parameters.

Posted: Mon Jul 09, 2007 4:20 pm
by Paul
ABBKlaus wrote:@Maxus,
Please supply a snippet for what is not working :wink:

This is from the TailBite manual and should work :
You can make your function accept variable arguments. To do so, you must include two or more ProcedureDLL's with the same name and an index number:

This use to work in TailBite for PB3.94

Code: Select all

ProcedureDLL.l MsgTest3(Line.s,Title.s,Icon.l)
  MessageRequester(Title,Line,Icon)
EndProcedure

ProcedureDLL.l MsgTest2(Line.s,Title.s)
  MsgTest3(Line,Title,#MB_ICONINFORMATION)
EndProcedure

ProcedureDLL.l MsgTest(Line.s)
  MsgTest3(Line,"Hello",#MB_ICONINFORMATION)
EndProcedure
And your arguments would be...
MsgTest(Line.s [, Title.s [, Icon.l]])

If you TailBite this code for PB4.x you get...
MsgTest(Line.s [, Title.s , Icon.l])

Latest TailBite seems to only recognize 1 additional argument, not multiple arguments.

Posted: Mon Jul 09, 2007 5:31 pm
by Maxus

Code: Select all

ProcedureDLL DEbuger_Init()
  Global ST=1
EndProcedure

ProcedureDLL.l MSGBOX(String.s, FColor.l)
  If Not IsWindow(0)
    ExamineDesktops()
    LoadFont(0,"Sans Serif",8,#PB_Font_Bold)
    OpenWindow(0,0,0,DesktopWidth(0),400,"Debug"):CreateGadgetList(WindowID(0))
    ListIconGadget(0,5,5,DesktopWidth(0)-10,390,"Message",DesktopWidth(0)-31,#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect)
    SetGadgetFont(0,FontID(0))
  EndIf
  AddGadgetItem(0,-1,String$)
  If Fcolor=-1:Fcolor=0:EndIf
  SetGadgetItemColor(0,CountGadgetItems(0)-1,#PB_Gadget_FrontColor,FColor)
  If ST=0
    SetGadgetItemColor(0,CountGadgetItems(0)-1,#PB_Gadget_BackColor,$EEEEEE):ST=1
  Else
    SetGadgetItemColor(0,CountGadgetItems(0)-1,#PB_Gadget_BackColor,$FFFFFF):ST=0
  EndIf
EndProcedure


ProcedureDLL.l MSGBOX2(String$)
  MSGBOX(String$,-1)
EndProcedure

ProcedureDLL DECL()
  ClearGadgetItemList(0)
EndProcedure

ProcedureDLL DEbuger_End()
If IsWindow(0)
  Repeat
  Until WindowEvent()=#PB_Event_CloseWindow
EndIf
EndProcedure 
This code not work in PB 4.10b2

What's wrong? ? ?

Posted: Mon Jul 09, 2007 6:08 pm
by ABBKlaus
@Paul
i know this worked in PB3.94 but i don´t have that sources anymore :( (TailBite1.3B0.1)
this works in the current version of TailBite :

Code: Select all

Declare.l MsgTest3(Line.s,Title.s,Icon.l)

ProcedureDLL.l MsgTest(Line.s) 
  MsgTest3(Line,"Hello",#MB_ICONINFORMATION) 
EndProcedure 

ProcedureDLL.l MsgTest2(Line.s,Title.s) 
  MsgTest3(Line,Title,#MB_ICONINFORMATION) 
EndProcedure 

ProcedureDLL.l MsgTest3(Line.s,Title.s,Icon.l) 
  MessageRequester(Title,Line,Icon) 
EndProcedure 
@Maxus :
some typing errors with string$/string.s and i prefer internal procedures. That way you can use optional parameters :wink:

Code: Select all

ProcedureDLL DEbuger_Init() 
  Global ST=1 
  Global Window_MSGBox
  Global Font_SansSerif
  Global ListIcon_MSGBox
EndProcedure 

Procedure.l ipf_MSGBOX(String.s, FColor.l=-1) 
  If Not IsWindow(Window_MSGBox) 
    ExamineDesktops() 
    Font_SansSerif=LoadFont(#PB_Any,"Sans Serif",8,#PB_Font_Bold) 
    Window_MSGBox=OpenWindow(#PB_Any,0,0,DesktopWidth(0),400,"Debug"):CreateGadgetList(WindowID(Window_MSGBox)) 
    ListIcon_MSGBox=ListIconGadget(#PB_Any,5,5,DesktopWidth(0)-10,390,"Message",DesktopWidth(0)-31,#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect) 
    SetGadgetFont(ListIcon_MSGBox,FontID(Font_SansSerif)) 
  EndIf 
  AddGadgetItem(ListIcon_MSGBox,-1,String) 
  If Fcolor=-1:Fcolor=0:EndIf 
  SetGadgetItemColor(ListIcon_MSGBox,CountGadgetItems(ListIcon_MSGBox)-1,#PB_Gadget_FrontColor,FColor) 
  If ST=0 
    SetGadgetItemColor(ListIcon_MSGBox,CountGadgetItems(ListIcon_MSGBox)-1,#PB_Gadget_BackColor,$EEEEEE):ST=1 
  Else 
    SetGadgetItemColor(ListIcon_MSGBox,CountGadgetItems(ListIcon_MSGBox)-1,#PB_Gadget_BackColor,$FFFFFF):ST=0 
  EndIf 
EndProcedure 


ProcedureDLL.l MSGBOX(String.s) 
  ipf_MSGBOX(String) 
EndProcedure 

ProcedureDLL.l MSGBOX2(String.s,FColor.l) 
  ipf_MSGBOX(String,FColor) 
EndProcedure 

ProcedureDLL DECL() 
  ClearGadgetItemList(ListIcon_MSGBox) 
EndProcedure 

ProcedureDLL DEbuger_End() 
  If IsWindow(Window_MSGBox) 
    Repeat 
    Until WindowEvent()=#PB_Event_CloseWindow 
  EndIf 
EndProcedure 
PS:
the order of the functions is essential in the current version of TailBite :!:

Right usage :

Code: Select all

ProcedureDLL SomeFunction(Param1)
EndProcedure

ProcedureDLL SomeFunction2(Param1,Param2)
EndProcedure

ProcedureDLL SomeFunction3(Param1,Param2,Param3)
EndProcedure
Regards Klaus

Posted: Mon Jul 09, 2007 7:35 pm
by Maxus
ABBKlaus - Thanks this method working. :lol:

Posted: Mon Jul 09, 2007 8:07 pm
by ABBKlaus
update is out : TailBite v1.3 PR 1.848

- should be more VISTA compatible now, TailBite_Intstaller.exe + TBUpdater.exe now request administrator mode
would be nice if someone could test this, i don´t have vista atm :oops:
- fixed : the preferences are loaded correctly now
- fixed : under some conditions the Compilers folder could be deleted
- added : Subsystem now changes accordingly to the checkboxes

Regards Klaus

Posted: Tue Jul 10, 2007 1:14 pm
by Progi1984
ABBKlaus wrote:same restrictions as ProcedureDLL, no optional parameters.
Excuse me but if I declare a prototype like this, MsgBox doesn't become a function...

Code: Select all

ProcedureDLL Lib_Init()
 OpenLibrary(0, "User32.dll")
Endprocedure

Prototype.l ProtoMessageBox(Fenetre.l, Corps$, Titre$, Options.l = 0)
Global MsgBox.ProtoMessageBox = GetFunction(0, "MessageBoxA")

Posted: Tue Jul 10, 2007 3:58 pm
by ts-soft
@Progi1984
Your MsgBox-Function is like a variable, so you can't export it in a lib.

You have to wrappe this in a ProcedureDLL like:

Code: Select all

Prototype.l ProtoMessageBox(Fenetre.l, Corps$, Titre$, Options.l)

ProcedureDLL Lib_Init()
  OpenLibrary(0, "User32.dll")
  Global MsgBox_.ProtoMessageBox = GetFunction(0, "MessageBoxA")
EndProcedure

Procedure MsgBox(Fenetre.l, Corps$, Titre$)
  ProcedureReturn MsgBox_(tre.l, Corps$, Titre$, 0)
EndProcedure

Procedure MsgBox2(Fenetre.l, Corps$, Titre$, Options.l)
  ProcedureReturn MsgBox_(tre.l, Corps$, Titre$, Options)
EndProcedure
but this make no sense :wink:

Posted: Tue Jul 10, 2007 4:07 pm
by Progi1984
Thanks you for your answer... i prefer in this case use Callfunction

Posted: Tue Jul 10, 2007 5:53 pm
by ABBKlaus
@TS-Soft :

small bug in your example :shock:

Code: Select all

Prototype.l ProtoMessageBox(Fenetre.l, Corps$, Titre$, Options.l=0) 

ProcedureDLL Lib_Init() 
  Global User32
  Global MsgBox_.ProtoMessageBox
  
  User32=OpenLibrary(#PB_Any, "User32.dll") 
  If User32
    MsgBox_ = GetFunction(User32, "MessageBoxA")
  EndIf
EndProcedure 

ProcedureDLL Lib_End() 
  If IsLibrary(User32)
    CloseLibrary(User32)
  EndIf
EndProcedure 

ProcedureDLL MsgBox(Fenetre.l, Corps$, Titre$) 
  If MsgBox_
    ProcedureReturn MsgBox_(tre.l, Corps$, Titre$) 
  EndIf
EndProcedure 

ProcedureDLL MsgBox2(Fenetre.l, Corps$, Titre$, Options.l) 
  If MsgBox_
    ProcedureReturn MsgBox_(tre.l, Corps$, Titre$, Options) 
  EndIf
EndProcedure
@Progi1984 please forget what i said about the prototypes and optional parameters, should work with it :oops:

Posted: Tue Jul 10, 2007 7:46 pm
by ts-soft

Code: Select all

OpenLibrary(0, "User32.dll") 
And in a lib you should use the dynamic IDs: #PB_Any ! (for all, not only for DLLs)

Posted: Tue Jul 10, 2007 8:13 pm
by ABBKlaus
ts-soft wrote:

Code: Select all

OpenLibrary(0, "User32.dll") 
And in a lib you should use the dynamic IDs: #PB_Any ! (for all, not only for DLLs)
good point ts-soft 8)
this should be true for all PB-ID´s !

PS: i replaced all examples above with #PB_Any´s

Posted: Wed Jul 11, 2007 10:57 am
by srod
@ABBKlaus : continued thanks for your great work. Just wondering though if you might create another thread where the latest versions of Tailbite could be easily found, i.e. the most up to date link kept permanently in the first post etc? As it is I always seem to miss the latest updates!

Thanks.


**EDIT: just compiled a lib with the unicode switch. Is this new version of Tailbite supposed to place the compiled lib in the unicode subsystem? In my case it is simply placing it in the regular PureLibraries\UserLibraries folder etc.

Posted: Wed Jul 11, 2007 4:48 pm
by ABBKlaus
@srod i will do that when i completed the new website for tailbite :wink: