define external function

declaration/definition

Syntax
define external result-type? function
       funcion-name argument-list?
       as external-name
       (in function-library library-name)?



Purpose

External functions are functions written in other languages that you call from your OmniMark program. External functions must be defined in your program, just like regular functions, except that the definition will point to an external function library that contains the function, instead of containing the body of the function. Generally speaking, the person who wrote the external function will provide an OmniMark include file or module that contains the necessary function definitions. All you have to do is include or import the appropriate file and call the function normally.

The form of an external function definition is as follows:

  define external switch function test-some-condition
  as "TestCond"
  in function-library "TestLib"

The in function-library parameter can be omitted if you provide a declare function-library statement to identify the function library in which the function is found.

  declare function-library "TestLib"
  
  define external switch function test-some-condition
  as "TestCond"

External string sink functions

An external string sink function establishes a sink for an OmniMark program so that data can be written to a destination that OmniMark cannot address itself. In the example below, the external string sink function establishes a sink for writing to a TCP/IP connection.

  define external string sink function create-writer
       to value string destination-name
  as "CreateWriter"

To write to an external sink, open a stream with the function call after the as in the open statement, and then establish the stream as current output:

  local stream my-response
  open my-response as create-writer to "response"
  using output as my-response
   output "Mary had a little lamb.%n"