<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE document PUBLIC "-//CNX//DTD CNXML 0.5 plus MathML//EN" "http://cnx.rice.edu/technology/cnxml/schema/dtd/0.5/cnxml_mathml.dtd">
<document xmlns="http://cnx.rice.edu/cnxml" xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" xmlns:m="http://www.w3.org/1998/Math/MathML" id="new">
  <name>Programming in LabVIEW MathScript-While Loops</name>
  <metadata>
  <md:version>1.2</md:version>
  <md:created>2006/08/02 12:40:42 GMT-5</md:created>
  <md:revised>2006/08/03 00:43:38.394 GMT-5</md:revised>
  <md:authorlist>
      <md:author id="aantonac">
      <md:firstname>Anthony</md:firstname>
      <md:othername>Gene</md:othername>
      <md:surname>Antonacci</md:surname>
      <md:email>aantonac@utk.edu</md:email>
    </md:author>
      <md:author id="morrell">
      <md:firstname>Darryl </md:firstname>
      
      <md:surname>Morrell</md:surname>
      <md:email>morrell@asu.edu</md:email>
    </md:author>
  </md:authorlist>

  <md:maintainerlist>
    <md:maintainer id="aantonac">
      <md:firstname>Anthony</md:firstname>
      <md:othername>Gene</md:othername>
      <md:surname>Antonacci</md:surname>
      <md:email>aantonac@utk.edu</md:email>
    </md:maintainer>
  </md:maintainerlist>
  
  <md:keywordlist>
    <md:keyword>LabVIEW</md:keyword>
    <md:keyword>M-File</md:keyword>
    <md:keyword>MathScript</md:keyword>
    <md:keyword>While Loops</md:keyword>
  </md:keywordlist>

  <md:abstract>This is a tutorial on using while loops in LabVIEW MathScript.</md:abstract>
</metadata>
  <content>
<section id="SecW">
	  <name>The While Loop</name>
<para id="ParaW">The <emphasis>while loop</emphasis> is similar to the for loop in that it allows the repeated execution of LABVIEW MATHSCRIPT statements. Unlike the for loop, the number of times that the LABVIEW MATHSCRIPT statements in the body of the loop are executed can depend on variable values that are computed in the loop.  The syntax of the while loop has the following form:
<code type="block">
while expression
    % LABVIEW MATHSCRIPT command 1
    % LABVIEW MATHSCRIPT command 2
    % More commands to execute repeatedly until expression is not true
end
</code>
where <code>expression</code> is a logical expression that is either true or false. (Information about logical expressions is available in <cnxn document="m13721">Programming in LABVIEW MATHSCRIPT-Logical Expressions</cnxn>.)
For example, consider the following while loop:
<code type="block">
n = 1
while n &lt; 3
    n = n+1
end
</code>
This code creates the following output:
<code type="block">
n =

     1

n =

     2

n =

     3
</code>
</para>
<para id="element-194">
Note that in all of this example, the LABVIEW MATHSCRIPT commands inside the while loop are indented relative to the <code>while</code> and <code>end</code> statements. This is not required by LABVIEW MATHSCRIPT but is common practice and makes the code much more readable.
</para>
</section>
  </content>
  
</document>
