swirl
Guide to OmniMark 9   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesLegacy LibrariesErrors
 
  Related Syntax   Related Concepts  
declaration/definition  

define external function

 
 

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"

    Related Syntax
 
Related Concepts
 
 

Top [ INDEX ] [ CONCEPTS ] [ TASKS ] [ SYNTAX ] [ LIBRARIES ] [ LEGACY LIBRARIES ] [ ERRORS ]

OmniMark 9.1.0 Documentation Generated: September 2, 2010 at 1:51:21 pm
If you have any comments about this section of the documentation, please use this form.

Copyright © Stilo International plc, 1988-2010.