Formatted data involves multiple kinds of data together. In this
example, we will read latitude and longitude data for a target.
Each direction is expressed in degrees, minutes, and hemisphere, so
that 44-20.00-N means a latitude of 44 degrees and 20.00 minutes
in the Northern hemisphere.
In the FileData section, strings are designated for the variable names
targlat and targlong. An integer is then designated for
each of the data parts in the formatted latitude/longitude data:
latitude degrees, latitude minutes, latitude hemisphere,
longitude degrees, longitude minutes, and longitude hemisphere.
In the FileStructure section, one record is programmed to read the
latitude and one record is programmed to read the longitude. For
the latitude, the entry in the input deck is targlat 44-20.00-N:
in other words, a seven-letter string, then four blank spaces,
then a two-digit integer, then a dash acting as a delimiter,
then a floating number in the format of two-digits/decimal/two-digits,
then a dash acting as a delimiter, and finally a one-letter string.
This translates into a format of (A6,4X,I2,A1,F5.2,A1,A1). Once the
format is set, then each of the latitude components can be read with a separate
SetValue. This process is repeated for longitude (note that the format
changes slightly, since targlong is an eight-letter string).
(A note about reading formatted data that contains delimiters: if the FSML file will be both reading and writing, then the processor must specifically read the delimiter into memory. This is the case with the example here, where the dash is a delimiter and is defined as format A1. Defining the delimiter as A1 stores the dash in memory so it can be written to a file. If, however, the FSML file is only reading, then the delimiter could be skipped: it does not matter what character is used as delimiter since it will not be written anywhere. In that case, the delimiter could be formatted as 1X and the FSML processor will ignore it during the read. For more discussion on the concept of the FSML read/write process, see Section 1.2.)
The flanking records for static text and target speed (targspeed)
are included only to show how formatted data handling
can be used with other types of elements.
Snippet from the Input Deck
*** Target Info *** targlat 44-20.00-N targlong 40-00.00-E targspeed 12.0
Snippet from the FSML File
<FileData>
<String name="targlat"/>
<String name="targlong"/>
<Integer name="targlatdeg" description="Target Latitude Degrees"/>
<Integer name="targlatmins" description="Target Latitude Minutes"/>
<Integer name="targlathemi" description="Target Latitude Hemisphere"/>
<Integer name="targlongdeg" description="Target Longitude Degrees"/>
<Integer name="targlongmins" description="Target Longitude Minutes"/>
<Integer name="targlonghemi" description="Target Longitude Hemisphere"/>
<Float name="targspeed" description="Target Speed"/>
</FileData>
<FileStructure>
<!-- Target Info -->
<StaticText>*** Target Info ***</StaticText>
<Record ignoreOnRead="false" format="(A7,4X,I2,A1,F5.2,A1,A1)">
<SetValue target="targlatname"/>
<SetValue target="targlatdeg"/>
<SetValue target="delimiter1"/>
<SetValue target="targlatmins"/>
<SetValue target="delimiter2"/>
<SetValue target="targlathemi"/>
</Record>
<Record ignoreOnRead="false" format="(A8,4X,I2,A1,F5.2,A1,A1)">
<SetValue target="targlongname"/>
<SetValue target="targlongdeg"/>
<SetValue target="delimiter1"/>
<SetValue target="targlongmins"/>
<SetValue target="delimiter2"/>
<SetValue target="targlonghemi"/>
</Record>
<Record ignoreOnRead="false">
<Separator ignoreOnRead="false" string="targspeed"/>
<SetValue target="targspeed"/>
</Record>
</FileStructure>