How it works

The Iteration operation 'while' evaluates the contents of the body repeatedly until a condition is met within the control. If the control is a store, the iteration repeats whilst the store exists.

The 'while' operation will evaluate the body whilst the input specified exists. The control is evaluated before each iteration, therefore there may be cases where the body is never evaluated. This will result in no ouput being generated.

'While' Example

Example: Execution per result

The following example tests for the existence of a sequence of files, and then outputs text to the first non existent file found.

<instruction>
	<output space="store" value="to_place"/>
	<input value="Bit of text to be placed."/>
</instruction>
<iteration operation="while">
	<control space="store" value="to_place"/>
	<body>
		<instruction operation="append">
			<output space="store" value="fname" />
			<input value="text_" />
			<input space="field" value="#row" />
			<input value=".txt" />
		</instruction>
		<comparison operation="existent">
			<comparate space="file" context="store" value="fname" />
			<onfalse>
				<instruction>
					<output space="file" context="store" value="fname" />
					<input space="store" value="to_place" release="true" />
				</instruction>
			</onfalse>
		</comparison>
	</body>
</iteration>



Last Modified: Thu, 15 Jan 2015