|
|||||
|
|||||
Filter Functions |
OmniMark supports "filter functions": external functions that can filter a source of data, or can filter while data is being written.
Earlier versions of OmniMark supported external "source" functions and external "output" functions:
define external source function TCPReader value stream addressPath as ... define external output function TCPWriter value stream addressPath as ...
Source and output functions primarily provide ways of communicating with the outside world in a streaming fashion.
Often some conversion of data is required on inbound or outbound data: for example, conversion on output from UTF-8 to one of the Japanese Industry Standard character codes, or conversion into an encrypted form, such as "Blowfish". Where this kind of functionality was provided pre-Version 7, it was done on a library-by-library basis. This meant most conversions weren't available for use with most libraries.
A pair of new features addresses this problem. Two new types are allowed to be specified for external function arguments: "source" and "output".
A source argument can be passed anything that can be scanned or submitted, including calls to external source functions. A source argument allows read-in data to be converted by the external function, and the converted data to be used as an input. Amongst other things, it can be passed to another filter function -- they can be chained together.
An output argument does the same thing as a source argument in the other direction: it can be any use of "file" or a call to an external output function of the sort that's allowed on the right-hand-side of an "open" action, following "as".
For Version 7, source and output arguments must be "value" arguments.
Here's what two of the new filter functions look like:
define external source function fromJIS208 value source input-data as ... define external output function toJIS208 value output output-data as ...