PBX_InvokeGlobalFunction

PowerBuilder Native Interface

Exported methods:

PBX_InvokeGlobalFunction method

Description

Contains the implementation of one or more global functions used in the PowerBuilder extension module.

Syntax

PBX_InvokeGlobalFunction(IPB_Session* pbsession, LPCTSTR functionname, PBCallinfo* ci); 

Argument

Description

pbsession

This IPB session

functionname

The name of the global function

ci

A pointer to a preallocated PBCallInfo structure containing the parameters and return value setting for the function

Return Values

PBXRESULT. PBX_OK for success.

Examples

This PBX_GetDescription call declares three global functions: bitAnd, bitOr, and bitXor:

PBXEXPORT LPCTSTR PBXCALL PBX_GetDescription()
{
   static const TCHAR desc[] = {
      "globalfunctions\n"
      "function int bitAnd(int a, int b)\n"
      "function int bitOr(int a, int b)\n"
      "function int bitXor(int a, int b)\n"
      "end globalfunctions\n"
   };

  return desc;
}

The PBX_InvokeGlobalFunction call contains the implementation of the functions:

PBXEXPORT PBXRESULT PBXCALL PBX_InvokeGlobalFunction
(
   IPB_Session*   pbsession,
   LPCTSTR        functionName,
   PBCallInfo*    ci
   )
{

  PBXRESULT pbrResult = PBX_OK;

  int arg1 = ci->pArgs->GetAt(0)->GetInt();
  int arg2 = ci->pArgs->GetAt(1)->GetInt();

  if (stricmp(functionName, "bitand") == 0)
  {
     ci->returnValue->SetInt(arg1 & arg2);
  }else if (strcmp(functionName, "bitor") == 0)
  {
     ci->returnValue->SetInt(arg1 | arg2);
  }else if (strcmp(functionName, "bitxor") == 0)
  {
     ci->returnValue->SetInt(arg1 ^ arg2);
  }else
  {
     return PBX_FAIL;
  }

  return pbrResult;
}

Usage

Use this function in a PowerBuilder native class that uses global functions. The function is exported from the PowerBuilder extension module and is used to identify global functions included in the module. Like global functions in PowerScript, global functions in PowerBuilder extensions cannot be overloaded.

See Also