mif.pl Write Routines

#

Write Routines

The following routines to write Frame MIF are defined in mif.pl:

- main'MIFwrite_open
- main'MIFwrite_close
- main'MIFwrite_statment
- main'MIFwrite_str_statment
- main'MIFescape_string

These routines are purely for convienence. One can output MIF markup directly, but these routines help hide the underlying syntax of MIF.

Note:
  Remember that ALL Perl variables mentioned are defined within the scope of package mif unless statements state/imply otherwise.

## Routine Descriptions

### MIFwrite_open

`&'MIFwrite_open(`FILEHANDLE`, $token, $indent);`

`MIFwrite_open` outputs the MIF to FILEHANDLE that opens `$token` with a character indent of `$indent`. Example:

    &'MIFwrite_open(STDOUT, `Pgf', 5);

would output:

         <Pgf

### MIFwrite_close

`&'MIFwrite_close(`FILEHANDLE`, $indent);`

`MIFwrite_close` outputs the MIF to FILEHANDLE that closes an open token with a character indent of `$indent`. Example:

    &'MIFwrite_close(STDOUT, 5);

would output:

         >

### MIFwrite_statment

`&'MIFwrite_statement(`FILEHANDLE`, $token, $data, $indent);`

`MIFwrite_statement` writes the MIF statement with token `$token` and data `$data`. `$indent` specifies the character indent of the statement. Example:

    &'MIFwrite_statement(STDOUT, 'Char', 'HardSpace', 4);

would output:

        <Char HardSpace>

### MIFwrite_str_statment

`&'MIFwrite_str_statement(`FILEHANDLE`, $token, $data, $indent);`

`MIFwrite_str_statement` writes the MIF string statement with token `$token` and string data `$data`. `$indent` specifies the character indent of the statement. Example:

    &'MIFwrite_str_statement(STDOUT, 'Paraline', 'Hello World!', 4);

would output:

        <Paraline `Hello World!'>

`MIFwrite_str_statement` adds the MIF string delimiters for you, so there is no need to add them yourself to `$data`. `MIFwrite_str_statement` assumes that `$data` is a valid MIF string. See MIFescape_string about converting a string to a valid MIF string.

### MIFescape_string

`&'MIFescape_string(*str);`

`MIFescape_string` escapes certain characters in `*str` to convert `*str` to a valid MIF string. The following characters are converted:

- '`\`' --> '`\\`'
- <tab> --> '`` '
- '`>`' --> '`\>`'
- '`'`' --> '`\q`'
- '```' --> '`\Q`'

Since a pointer to the string variable is passed in, modifications of the string are preserved after the routine returns. If you want to preserve the original string, you must make a copy of it before passing it to `MIFescape_string`.

As you can see, `MIFescape_string` is not really a write routine. The routine itself does not warrent its own page, and it is normally used in conjunction with MIFwrite_str_statment.

Go back to mif.pl.