next up previous contents
Next: 3.4 How to Process Up: 3 Examples Previous: 3.2.3 Multi-Dimensional Arrays (m   Contents


3.3 How to Process a Loop, and Looping Controls

As explained in Section 2.3.4, a loop repeats a certain operation under controlled conditions. In this example, the loop reads a column-oriented data file as three vertical arrays: one for time, one for temperature, and one for humidity. The number of records is the first entry in the input file. The FSML reads the first entry (in this case, 101) and designates it as the endpoint for the looping control. The loop then checks whether that endpoint has been reached; if not, it reads the next line of three arrays, increments the counter by 1 (set with the attribute for incr), and repeats.

Snippet from the Input Deck

101
00000  283.0000  76.2154
00010  283.0100  75.9284
00020  283.9514  74.5295
00030  284.6030  71.0012
00040  286.5713  68.6293
...
00980  313.5561  45.2142
00990  315.1357  44.2348
01000  317.9414  43.8304

Snippet from the FSML File

<FileData>
  <Integer name="numpoints"/>
  <Array name="time" ndims="1" dims="numpoints" baseType="Integer"/>
  <Array name="tempK" ndims="1" dims="numpoints" baseType="Float"/>
  <Array name="humid" ndims="1" dims="numpoints" baseType="Float"/>
</FileData>
 
<FileStructure>
  <Record ignoreOnRead="false">
    <SetValue target="numpoints"/>
  </Record>
  <Loop loopVariable="i" start="1" end="numpoints" incr="1" doOnce="false">
    <Record ignoreOnRead="false">
      <AddValue target="seconds"/>
      <AddValue target="tempK"/>
      <AddValue target="humid"/>
    </Record>
  </Loop>
</FileStructure>


next up previous contents
Next: 3.4 How to Process Up: 3 Examples Previous: 3.2.3 Multi-Dimensional Arrays (m   Contents

SAIC Ship Technology Division, Annapolis, Maryland, USA
2004-10-26