3.4 DM_BindFunctions

By means of this function, a table of functions can be transferred to DM, after having loaded the dialog. This function is very similar to the function DM_BindCallBacks; the difference is, however, that this function has to be used if the relevant dialog is structured in modules and if the functions have been defined in modules.

By using these functions, other functions defined in modules which have not been loaded yet can be linked to the dialog so that these functions can be called immediately after having loaded the module.

DM_Boolean DML_default DM_EXPORT DM_BindFunctions
(
  DM_FuncMap funcmap,
  DM_UInt funccount,
  DM_ID objID,
  DM_ID moduleID,
  DM_Options options
)

Parameters

-> DM_FuncMap funcmap

This parameter is the table of functions which can be directly called by DM. The structure of this table is described in the chapter on data structures. This table can be created automatically by the simulation program via the option +writefuncmap.

-> DM_UInt funccount

This parameter indicates the size of the transferred function table.

-> DM_ID objID

This parameter is the ID of the object to which this table is to be linked. This ID may be either a dialog, a module or an application.

-> DM_ID moduleID

This parameter is the ID of the module which is to supply its function immediately from this table. This ID has to be specified only if a module has been reloaded and if the functions are only then linked to the superordinate instance. Usually, the ID has to be specified by 0.

-> DM_Options options

Currently, the following values are possible:

Option

Meaning

DMF_ReplaceFunctions

This option means that a function table which probably exists has to be replaced completely by a new table at the indicated object. If this option is not specified, the new table will be attached at the end of an existing table of the object.

Example

A C file is created from a module via the +writefuncmap option. The dialog file has the following structure:

module ModFuncDate

application TimeServer

{

  !! Get the current date from the server to synchronize the

  !! clients

  !! example: CurrentDate( Year, Month, Day) returns true

  !! if successful and fills the three variables with the

  !! appropriate values

  function boolean CurrenDate( integer Year output,

    integer Month output, integer Day output);

 

  !! Get the current time, see function CurrentDate

  function boolean CurrentTime( integer Hour output,

    integer Minute output, integer Second output);

}

The generated C program looks as this:

#include "IDMuser.h"

#include "dateappl.h"

 

#define FuncCount_TimeServer (sizeof(FuncMap_TimeServer) / sizeof(FuncMap_TimeServer[0]))

 

static DM_FuncMap FuncMap_TimeServer[] =

{

/*

**  Get the current date from the server to synchronize the

**  clients

**  example: CurrentDate( Year, Month, Day) returns true

**  if successful and fills the three variables with the

**  appropriate values

*/

  { "CurrenDate", (DM_EntryFunc) CurrenDate },

/*

**  Get the current time, see function CurrentDate

*/

  { "CurrentTime", (DM_EntryFunc) CurrentTime },

}

 

DM_Boolean DML_default BindFunctions_TimeServer __3(

    (DM_ID, dialogID),

    (DM_ID, moduleID),

    (DM_Options, options))

{

return (DM_BindFunctions (FuncMap_TimeServer,

    FuncCount_TimeServer,dialogID,moduleID,options))

}