<?xml version="1.0" encoding="utf-8"?>

<ExportedUserProgram
    Version="1.0.0">
   <VariableTable>
   <Variable
       Offset="52"
       TagName="i"
       Format="DINT"
       DefaultValue="0"/>
   <Variable
       Offset="767"
       TagName="FillValue"
       Format="REAL"
       DefaultValue="4"/>
   <Variable
       Offset="768"
       TagName="MyArray"
       Format="REAL"
       ArraySize="65"
       DefaultValue="0"/>
</VariableTable>
   <DiscreteIO/>
   <UserProgram
    Name="FillArray"
    Type="STEP"
    Number="68"
    Desc="Filling Array of Unknown Size (up to some limit)&#13;&#10;------------------------------------------------------------------&#13;&#10;Filling an array of unknown size is a bit tricky since the Fill function is limited to filling 32 registers of an array. Here is one method.&#13;&#10;&#13;&#10;THis example is limited to arrays of length 128. To increase the max size, simply duplicate the last 4 lines in the expression as many times as necessary."
    SingleInstance="True"
    TaskMask="32767">
   <ProgramBlock
       Type="STEP">
      <Declarations
          Declarations="VAR&#13;&#10;&#9;i : DINT := 0;&#13;&#10;END_VAR"/>
      <Step>
         <Expression
             Src="FILL(MyArray,FillValue,MIN(LENGTH(MyArray),32));&#13;&#10;i:=32;&#13;&#10;IF LENGTH(MyArray) &gt; i THEN&#13;&#10;&#9;FILL(MyArray[i],FillValue,MIN(LENGTH(MyArray)-i,32));&#13;&#10;END_IF;&#13;&#10;i:=i+32;&#13;&#10;IF LENGTH(MyArray) &gt; i THEN&#13;&#10;&#9;FILL(MyArray[i],FillValue,MIN(LENGTH(MyArray)-i,32));&#13;&#10;END_IF;&#13;&#10;i:=i+32;&#13;&#10;IF LENGTH(MyArray) &gt; i THEN&#13;&#10;&#9;FILL(MyArray[i],FillValue,MIN(LENGTH(MyArray)-i,32));&#13;&#10;END_IF;"/>
      </Step>
      <Transition>
         <End/>
      </Transition>
   </ProgramBlock>
</UserProgram>
</ExportedUserProgram>
