# 15 Programming Your Own Output Filter

VIEWMOL can be easily adapted to write files in any format. All you have to do is to write a new output filter which formats the data provided by VIEWMOL. These output filters are stand-alone programs and can be written in every programming language you want. Examples in awk are included.

The output filter has to accept the following data from its standard input and write them to a file whose name is given as a command line parameter to the filter. VIEWMOL passes the following data groups to the output filter:

- the unit cell (if present) is sent in the following format (a, b, and c in atomic units, the angle in degrees)

        $unitcell a b c alpha beta gamma

- the cartesian coordinates are sent in the following format (in atomic units)

        $coord
         x1   y1   z1   symbol1
         x2   y2   z2   symbol2
         ...

- the bond information is sent in the following format

        $bonds
         atom1 atom2 bond_order
         ...

  where `atom1` and `atom2` are the numbers of the atoms according to the list in `$coord` which form the bond. `bond_order` is the actual order of the bond, -2 if the bond is part of a conjugated system, or -1 if it is a hydrogen bond.

`$end` is passed to the output filter as last line.