Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

BIF Definition  (as per DC@F47 file on IBM i/ LX_F47 file on Windows)

BIF Name:

UD_AVERAGE

Unique Identifier:

413

Description:

Retrieve a system value

Call or Execute:

Program Name:

U_BIF413

Terminates between calls:

N     (Y or N)

Number of arguments:

2

Number of return values:

1

BIF Arguments  (as per DC@F47 file on IBM i/ LX_F47 file on Windows)
Parameter 1

BIF Name:

UD_AVERAGE

Parameter Type

ARG

Parameter Sequence:

1

Parameter Number:

1

Parameter Identifier:

A

Description:

First Value

Required / Optional:

R    (R or O)

Parameter Type:

N    (A, N or L)

Minimum Length:

7

Maximum Length:

7

Minimum Decimal:


Maximum Decimal:


Pass Length:

10

Pass Decimal:


Default:


Parameter 2

BIF Name:

UD_AVERAGE

Parameter Type

ARG

Parameter Sequence:

2

Parameter Number:

2

Parameter Identifier:

B

Description:

Second Value

Required / Optional:

R    (R or O)

Parameter Type:

N    (A, N or L)

Minimum Length:

7

Maximum Length:

7

Minimum Decimal:


Maximum Decimal:


Pass Length:

10

Pass Decimal:


Default:


BIF Return Values  (as per DC@F47 file on IBM i/ LX_F47 file on Windows)

BIF Name:

UD_AVERAGE

Parameter Type

RET

Parameter Sequence:

1

Parameter Number:

3

Parameter Identifier:

C

Description:

Mean Value

Required / Optional:

R     (R or O)

Parameter Type:

A     (A, N or L)

Minimum Length:

7

Maximum Length:

7

Minimum Decimal:


Maximum Decimal:


Pass Length:

256

Pass Decimal:


Now, enter the data into the Built-In Function definition files:

     /* =============================================================== */
/* ========== USER DEFINED BUILT-IN FUNCTION DEFINITION ========== */
/* =============================================================== */
/*                                                                 */
/* This is a sample of how a user defined built-in function may be  */
/* defined. It is provided as an example only. No warranty of any   */
/* kind is expressed or implied. The programmer copying this code   */
/* is responsible for the implementation and maintenance of this    */
/* function, both initially and at all times in the future.         */
/*                                                                  */
/* User defined built-in functions are a powerful facility. However,*/
/* you should note that YOU are responsible for any impact the      */
/* use of a user defined built-in function has on the performance,  */
/* security, integrity, portability and maintainability of your     */
/* applications.                                                    */
/*                                                                  */
/* ================================================================ */
/*                                                                  */
/* Source File               : U_BIF413.C                           */
/* Entry Point Name          : U_Builtin_413                       */
/* Linked DLL Name           : U_BIF413.DLL                         */
/* Shared Object Name        : u_bif413.O                           */
/* OS/Dependencies           : Yes/No                               */
/*                                                                  */
/* Amendment History   :                                            */
/*                                                                  */
/* Task Id  Date    Description                                     */
/* =======  ====    ===========                                     */
/*                                                                  */
/* ================================================================ */
#define U_BIF_FUNCTION       U_Builtin_413
#define U_BIF_FUNCTION_NAME "U_Builtin_413"
#define U_BIF_DESCRIPTION   "This is a description of this built-in"

#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>

#include "x_glodef.h"
#include "x_glousr.h"

#ifdef X_OPERATING_SYSTEM_WIN
#include <windows.h>
#endif

#include "x_funstr.h"
#include "x_funpro.h"
#include "x_bif000.h"

/*==================================================================*/
/*                                                                  */
/* Arguments    : pX_Ids       - Standard X_IDS system definition   */
/*                pX_Pro       - Standard X_PRO process definition  */
/*                pX_Fun       - Standard X_FUN function definition */
/*                pX_Bif       - Standard X_BIF built-in definition */
/*                X_Fld[:      - Standard X_FLD field definitions   */
/*                X_List[:     - Standard X_LIST list definitions   */
/*                sInCount     - Number of arguments passed in      */
/*                sInVec[:     - Vectors of arguments               */
/*                sRetCount    - Number of return values            */
/*                sRetVec[:    - Vectors of return values           */
/*==================================================================*/
 X_VOID_FUNCTION U_BIF_FUNCTION ( U_BIF_STANDARD_PARAMETERS )
{

   /* ------------------------------------------------------------- */
   /* Handle a shutdown request (usually no activity is required)   */
   /* ------------------------------------------------------------- */
    if (U_BIF_SHUTDOWN_REQUEST)
   {
      U_BIF_SET_GOOD_RETURN
   }
   /* ------------------------------------------------------------- */
   /* Else perform the requested activity                           */
   /* ------------------------------------------------------------- */
    else
   {
      X_LONG lArg1;
      X_LONG lArg2;
      X_LONG lAverage;

      /* ------------------------------------- */
      /* Get argument 1 (C convention is 0)    */
      /* and argument 2 (C convention is 1)    */
      /* and compute their average             */
      /* ------------------------------------- */

       U_BIF_GET_ARG_AS_LONG (0,lArg1)
       U_BIF_GET_ARG_AS_LONG (1,lArg2)
       lAverage = (lArg1 + lArg2) / 2;

      /* ------------------------------------- */
      /* Return the result in return value 1   */
      /* (C convention is  0)                  */
      /* ------------------------------------- */

        U_BIF_SET_RET_FROM_LONG (0, lAverage);

      /* ------------------------------------- */
      /* Set a "good" return (Operating Level) */
      /* ------------------------------------- */
       U_BIF_SET_GOOD_RETURN
   }
   /* ------------------------------------------------------------- */
   /* Return control to caller                                      */
   /* ------------------------------------------------------------- */
    U_BIF_RETURN;
}

Some significant things to note about this example are:

...