Gambas Documentation
Como se hace...
Compilación e instalación
Componentes
Controls pictures
Descripciones del Lenguaje
Developer Documentation
Componentes adicionales de Gambas
Cómo programar componentes en C/C++
Cómo programar componentes en Gambas
Índice Alfabético de la Interfaz de Programación de Gambas
Índice por Categorías de la Interfaz de Programación de Gambas
Name
ARG
BEGIN_METHOD_VOID
BEGIN_PROPERTY
END_METHOD
GB.Add
GB.Alloc
GB.Application.Name
GB.Application.Title
GB.Array.Count
GB.CheckPost
GB.CurrentComponent
GB.Detach
GB.ExistClass
GB.ExistFile
GB.FileName
GB.Free
GB.FreeArray
GB.FreeString
GB.GetClass
GB.GetClassName
GB.GetEnum
GB.GetEvent
GB.GetFunction
GB.GetTempDir
GB.GetTime
GB.GetUnknown
GB.Is
GB.ListEnum
GB.LoadComponent
GB.NewString
GB.NextEnum
GB.Propagate
GB.Push
GB.Realloc
GB.Ref
GB.ReleaseFile
GB.ReturnFloat
GB.ReturnLong
GB.ReturnObject
GB.StopAllEnum
GB.StopEnum
GB.StoreObject
GB.StoreString
GB.StoreVariant
GB.System.Language
GB.Unref
GB.Watch
GB_ARRAY
GB_FLOAT
GB_HOOK_LOOP
GB_HOOK_MAIN
GB_HOOK_POST
GB_HOOK_TIMER
GB_STRING
GB_T_BOOLEAN
GB_T_BYTE
GB_T_DATE
GB_T_FLOAT
GB_T_INTEGER
GB_T_LONG
GB_T_SHORT
GB_T_SINGLE
GB_T_STRING
GB_T_VARIANT
GB_TIMER
PROP
VPROP
Documentacion y Recetas
Documentación del Entorno de Desarrollo
Fragmentos de código
Glosario
Índice del Lenguaje
LÉEME
Licencia del Wiki
Manual del Wiki
Mensajes de Error
Pendiente de traducción
Registrarse
Repositorio de Aplicaciones
Tutoriales
Últimos cambios

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 /wiki/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