contentsconceptssyntaxlibrariessampleserrorsindex
Full text search
Input/Output
    Related Syntax  

Stream processing is at the heart of OmniMark. As a streaming language, OmniMark handles input and output at the core of the language. OmniMark maintains a current input and all recognition of data events is performed on the current input. Similarly, OmniMark maintains a current output at all times, and all output is directed to the current output. This greatly simplifies processing, since you never need to specify what data an action operates on or what destination output goes to. You simply set the current input and output to the appropriate streams and go.

OmniMark defines a number of default streams that correspond to the standard input, standard output, and standard error streams of the underlying operating system.

(Windows programmers may not be familiar with these concepts, which apply in command-line environments. Standard input is where input comes from by default: in most cases, the keyboard. Standard output is where output of a program goes by default, usually to the screen. Standard error is where error messages go by default, usually to the screen. Some operating systems provide sophisticated facilities for manipulating standard input, output, and error. A Windows DOS box provides standard input, output, and error. Under Windows, OmniMark runs in a DOS box.)

In OmniMark, #process-input is a stream bound to standard input, #process-output is a stream bound to standard output, and #error is a stream bound to standard error.

#main-input is a stream that is bound to standard input unless you specify an input file or files on the command line, in which case, #main-input is bound to those files. Similarly, #main-output is bound to standard output unless you specify an output file on the command line, in which case, #main-output is bound to that file.

By default, in aided translation type programs OmniMark's current input is #main-input and its current output is #main-output. Current input and current output may change many times in the course of a program, but #main-input and #main-output never change. Despite its name, however, output only goes to #main-output when it is attached to the current output. As you might expect, OmniMark's current output can be referred to as #current-output. In normal programs #current-input is unattached by default.

Of course, you don't have to deal with #main-input and #main-output at all if you don't want to. You can always explicitly assign current input and current output to files from within your code. Since OmniMark has no direct user interface functions, however, the command line is the principal way to pass input and output file names into a batch style OmniMark program.

Server style OmniMark programs communicate with a variety of clients over TCP/IP networks and can receive file names and other instructions from the client. Since OmniMark servers run in the background, there is often no point in dealing with any local input and output streams. If you are writing a server you may wish to disable all the default input and output streams with declare no-default-io.

To explicitly assign current input to a file use submit, do sgml-parse, or do xml-parse with the file modifier:

  submit file "mary.txt"

  do xml-parse document
     scan file "mary.xml"
     output "%c"
  done

You can even assign multiple files to be processed sequentially:

  submit file "mary.txt" || file "lamb.txt"

  do sgml-parse document
     scan file "sgmldec.sgm" || file "rhymes.dtd" || file "mary.xml"
     output "%c"
  done

All other OmniMark actions that initiate text or markup processing, such as do scan, also accept files in just the same way. If you can process a string, you can process a file by replacing the stream variable or literal string with file and the name of the file. In all cases, doing so sets the current input to the named file.

      Related Syntax
   #current-output
   #error
   #main-input
   #main-output
   do sgml-parse
   do xml-parse
   submit
 
----

Top [CONTENTS] [CONCEPTS] [SYNTAX] [LIBRARIES] [SAMPLES] [ERRORS] [INDEX]

Generated: April 21, 1999 at 2:00:49 pm
If you have any comments about this section of the documentation, send email to [email protected]

Copyright © OmniMark Technologies Corporation, 1988-1999.