Gambas Documentation
Application Repository
Code Snippets
Compilation & Installation
Components
Controls pictures
Deprecated components
Developer Documentation
'gb.qt' implementation details
Additional Gambas Components
Gambas Programming Interface
Cat
Name
ARG
BEGIN_METHOD
BEGIN_METHOD_VOID
BEGIN_PROPERTY
DECLARE_EVENT
DECLARE_METHOD
DECLARE_PROPERTY
END_METHOD
END_PROPERTY
GB.Add
GB.AddString
GB.Alloc
GB.Application.Name
GB.Application.Path
GB.Application.Startup
GB.Application.Title
GB.Application.Version
GB.Array.Add
GB.Array.Count
GB.Array.Get
GB.Array.New
GB.Attach
GB.AutoCreate
GB.Call
GB.CanRaise
GB.CheckObject
GB.CheckPost
GB.Collection.Count
GB.Collection.Get
GB.Collection.New
GB.Collection.Set
GB.Conv
GB.ConvString
GB.Count
GB.CurrentComponent
GB.Detach
GB.Error
GB.ExistClass
GB.ExistFile
GB.ExtendString
GB.FileName
GB.FindClass
GB.Free
GB.FreeArray
GB.FreeString
GB.GetClass
GB.GetClassName
GB.GetEnum
GB.GetEvent
GB.GetFunction
GB.GetInterface
GB.GetTempDir
GB.GetTime
GB.GetUnknown
GB.HashTable.Add
GB.HashTable.Count
GB.HashTable.Enum
GB.HashTable.Free
GB.HashTable.Get
GB.HashTable.New
GB.HashTable.Remove
GB.Hook
GB.Insert
GB.Is
GB.IsProperty
GB.ListEnum
GB.LoadComponent
GB.LoadFile
GB.MakeDate
GB.MakeDateFromTime
GB.MatchString
GB.New
GB.NewArray
GB.NewString
GB.NewZeroString
GB.NextEnum
GB.NParam
GB.NumberFromString
GB.NumberToString
GB.Post
GB.Propagate
GB.Push
GB.Raise
GB.RaiseTimer
GB.RealFileName
GB.Realloc
GB.Ref
GB.ReleaseFile
GB.Remove
GB.ReturnBoolean
GB.ReturnConstString
GB.ReturnConstZeroString
GB.ReturnDate
GB.ReturnFloat
GB.ReturnInteger
GB.ReturnLong
GB.ReturnNewString
GB.ReturnNewZeroString
GB.ReturnNull
GB.ReturnObject
GB.ReturnPtr
GB.ReturnString
GB.SplitDate
GB.StopAllEnum
GB.StopEnum
GB.Store
GB.StoreObject
GB.StoreString
GB.StoreVariant
GB.strcasecmp
GB.Stream.Init
GB.StringLength
GB.strncasecmp
GB.SubstAdd
GB.SubstString
GB.System.Charset
GB.System.Language
GB.tolower
GB.toupper
GB.ToZeroString
GB.Unref
GB.UnRefKeep
GB.Watch
GB_ARRAY
GB_AUTO_CREATABLE
GB_BASE
GB_BOOLEAN
GB_CLASS
GB_COLLECTION
GB_COMP_BINARY
GB_COMP_TEXT
GB_CONSTANT
GB_DATE
GB_DATE_SERIAL
GB_DECLARE
GB_DESC
GB_END_DECLARE
GB_ERR_ARG
GB_ERR_BOUND
GB_ERR_NPROPERTY
GB_ERR_NSYMBOL
GB_ERR_TYPE
GB_EVENT
GB_FLOAT
GB_FUNCTION
GB_HASHTABLE
GB_HASHTABLE_ENUM_FUNC
GB_HOOK_CHECK
GB_HOOK_ERROR
GB_HOOK_LANG
GB_HOOK_LOOP
GB_HOOK_MAIN
GB_HOOK_POST
GB_HOOK_QUIT
GB_HOOK_TIMER
GB_HOOK_WAIT
GB_HOOK_WATCH
GB_INHERITS
GB_INTEGER
GB_LONG
GB_METHOD
GB_NB_LOCAL
GB_NB_READ_ALL
GB_NB_READ_FLOAT
GB_NB_READ_HEX_BIN
GB_NB_READ_INT_LONG
GB_NB_READ_INTEGER
GB_NB_READ_LONG
GB_NOT_CREATABLE
GB_OBJECT
GB_POINTER
GB_PROPERTY
GB_PROPERTY_READ
GB_PROPERTY_SELF
GB_SINGLE
GB_STATIC_METHOD
GB_STATIC_PROPERTY
GB_STATIC_PROPERTY_READ
GB_STATIC_PROPERTY_SELF
GB_STREAM
GB_STREAM_DESC
GB_STRING
GB_SUBST_CALLBACK
GB_T_BOOLEAN
GB_T_BYTE
GB_T_CSTRING
GB_T_DATE
GB_T_FLOAT
GB_T_INTEGER
GB_T_LONG
GB_T_NULL
GB_T_OBJECT
GB_T_POINTER
GB_T_SHORT
GB_T_SINGLE
GB_T_STRING
GB_T_VARIANT
GB_T_VOID
GB_TIMER
GB_TYPE
GB_VALUE
GB_VARIANT
GB_VIRTUAL_CLASS
GB_WATCH_CALLBACK
GB_WATCH_NONE
GB_WATCH_READ
GB_WATCH_READ_WRITE
GB_WATCH_WRITE
LENGTH
MISSING
PLENGTH
PROP
PSTRING
READ_PROPERTY
RETURN_SELF
STRING
VARG
VARGOPT
VPROP
How To Program Components In C/C++
How To Program Components In Gambas
Development Environment Documentation
Documents
Error Messages
Gambas Playground
How To's
Language Index
Language Overviews
Last Changes
Lexicon
README
Search the wiki
To Do
Topics
Tutorials
Wiki License
Wiki Manual

GB.Hook

void *GB.Hook ( int type , void *hook )

Installs a global interpreter hook.

  • type is an integer constant that identifies the hook.

  • hook is the hook function pointer.

The GB.Hook function returns the previous hook, so that you can call it yourself if necessary. I think this is useful only to the GB_HOOK_MAIN hook.

There are eight global hooks:

Name Description
GB_HOOK_MAIN
void hook_main ( int *argc, char **argv )

This hook is called to parse the command line.

  • argc is a pointer to the number of arguments.

  • argv is an array of strings containing the arguments, like the one received by the main function.

If you consume process arguments in argv, then you have to remove them from it and modify *argc accordingly.
GB_HOOK_LOOP
int hook_loop ( void )

This hook is called to enter the event loop until the program ends.

The return value should be the value that must be returned by the program.
GB_HOOK_WAIT
void hook_wait ( long duration )

This hook is called to implement the WAIT instruction.

You must watch the event loop at most during the number of milliseconds specified by duration, and then return.
GB_HOOK_TIMER
void hook_timer ( GB_TIMER *timer, int enabled )

This hook is called to start or stop a timer.

  • timer points at the timer object. All needed information is found inside.

  • enabled is TRUE is the timer must be activated, or FALSE if it must be stopped.

The GB_TIMER structure includes a field named id, that you have to set to a number that uniquely identifies the timer. This identifier must be reset to zero when the timer is stopped.
GB_HOOK_LANG
void hook_lang ( char *lang , int rtl )

This hook is called when the current language changes.

  • lang is the new language set

  • rtl will tell you if this language is right-to-left written.

GB_HOOK_WATCH
void hook_watch ( int fd , int type , void *callback , long param )

This hook is called to implement the watch of file descriptors.

  • fd is the file descriptor to watch.

  • type is one of the constants specified in /edit/api/cat/watch.

  • param is the parameter registered when calling GB.Watch.

GB_HOOK_POST
void hook_post ( void )

This hook is called to execute callback functions at the next call of the event loop.
GB_HOOK_QUIT
void hook_quit ( void )
This hook is called when the QUIT instruction is used.

You should clean and release everything you can.
GB_HOOK_ERROR
void hook_error ( int code , char *error , char *where )

This hook is called to display error messages.

  • code is the error code.

  • error is the error message.

  • where is a string that describes where the error occured.

See also