Segment definitions are tables as well which describe one field on each row. On the header of the table there is the sequence of keywords `SEQ', `LEN' etc. The tables are again surrounded by empty lines. Following each table, there is a section which starts with the keyword `FIELD NOTES:', followed on the same line with the id of the segment. Even though, we take the segment id from the subsection headline, which precedes the tables, we reassure us from the correctness of our assumption with the help of the `FIELD NOTES:' construct, which turned out to be very reliable.
Please note, that we can not define a completely secure method at the outset, by which we find any piece of information without fail, but we rather refine our method as far as seems reasonable by trial and error, trying to catch most misinterpretations by taking advantage of redundancies found in any human readable text.
The extraction of segment definitions is done by `bin/exseg', which in turn runs AWK with `bin/exseg.awk' on its first parameter (which typically is a file name), pipes the output through several sed processes and prints its output to the standard output stream (which is typically redirected into a file).
We build the interim table with the name `SEGMENT' to be defined and followed by the column specification lines, which are the same for any segment. Then we convert the body of the table into the canonical format, replacing VTs by colons. We are in some trouble here, because some VTs have been mutated to consecutive spaces, thus we cannot savely discriminate columns. The only reasonable way to cope with these kind of problems seemed to manually edit the defect output. It is hoped, that any next version will be free of these problems, such that there is no use wasting time extending generality to cover faulty conditions.
There is reason for extracting the field notes as well. We will find, that there are fields declared as being of ID type, which actually are a kind of a composite types. This applies for fields, that deal with patient location. Actually we don't use the field notes a lot, but it might be useful, if we'd store the whole information in a database, or hypertext file. Field notes are extracted with `bin/exfld', which is itself an AWK script.