[next] [previous] [contents]

  20.2.2 Declaring an External Routine and Its Arguments
  To call an external routine or system routine you need to
  declare it as an external procedure or function and to de-
  clare the names, data types, and passing mechanisms for the
  arguments. Arguments can be either required or optional.

  You should include the following information in a routine
  declaration:

  .
        The name of the external routine
  .
        The data types of all the routine parameters
  .
        The passing mechanisms for all the routine parameters,
        provided that the routine is not written in BASIC

  When you declare an external routine, use the EXTERNAL
  statement. This allows you to specify the data types and
  parameter-passing mechanisms only once.

  In the following example, the EXTERNAL statement declares
  cobsub
as an external subprogram with two parameters-a
  LONG integer and a string both passed by reference:
  EXTERNAL SUB cobsub (LONG BY REF, STRING BY REF)

  With the EXTERNAL statement, BASIC allows you to spec-
  ify that particular parameters do not have to conform to
  specific data types and that all parameters past a certain
  point are optional. A parameter declared as ANY indicates
  that any data type can appear in the parameter position. In
  the following example, the EXTERNAL statement declares a
  SUB subprogram named allocate . This subprogram has three
  parameters: one LONG integer, and two that can be of any
  BASIC data type.
  EXTERNAL SUB allocate(LONG, ANY,)

  A parameter declared as OPTIONAL indicates that all fol-
  lowing parameters are optional. You can have both required
  and optional parameters. The required parameters, how-
  ever, must appear before the OPTIONAL keyword because
  all parameters following it are considered optional.

  In the following example, the EXTERNAL statement de-
  clares the Run-Time Library routine LIB$LOOKUP_KEY.
  The keyword OPTIONAL is specified to indicate that the last
  three parameters can be optional.
  
EXAMPLE: Click to display example.

  For more information about using the EXTERNAL state-
  ment, see the DEC BASIC and VAX BASIC for OpenVMS
  Systems Reference Manual
.