<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE document PUBLIC "-//CNX//DTD CNXML 0.5 plus MathML//EN" "http://cnx.rice.edu/cnxml/0.5/DTD/cnxml_mathml.dtd">
<document xmlns="http://cnx.rice.edu/cnxml" xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="None">
  <name>Auto-Indexing</name>
  <metadata>
  <md:version>**new**</md:version>
  <md:created>2004/06/18 10:47:27.241 GMT-5</md:created>
  <md:revised>2004/07/01 11:36:37.959 GMT-5</md:revised>
  <md:authorlist>
      <md:author id="NationalInstruments">
      <md:firstname>National</md:firstname>
      
      <md:surname>Instruments</md:surname>
      <md:email>certification@ni.com</md:email>
    </md:author>
  </md:authorlist>

  <md:maintainerlist>
    <md:maintainer id="lizzardg">
      <md:firstname>Elizabeth</md:firstname>
      
      <md:surname>Gregory</md:surname>
      <md:email>lizzardg@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer id="mshiralkar05">
      <md:firstname>Malan</md:firstname>
      
      <md:surname>Shiralkar</md:surname>
      <md:email>mshiralkar05@hotmail.com</md:email>
    </md:maintainer>
    <md:maintainer id="harika">
      <md:firstname>Harika</md:firstname>
      
      <md:surname>Basana</md:surname>
      <md:email>ilsai@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer id="NationalInstruments">
      <md:firstname>National</md:firstname>
      
      <md:surname>Instruments</md:surname>
      <md:email>certification@ni.com</md:email>
    </md:maintainer>
  </md:maintainerlist>
  
  <md:keywordlist>
    <md:keyword>National Instruments</md:keyword>
    <md:keyword>LabVIEW</md:keyword>
    <md:keyword>Auto-Indexing</md:keyword>
    <md:keyword>auto-indexing</md:keyword>
    <md:keyword>auto</md:keyword>
    <md:keyword>indexing</md:keyword>
  </md:keywordlist>

  <md:abstract>In this section, you will learn about Auto-Indexing.</md:abstract>
</metadata>
  
  <content>
    <para id="para1">
      If you wire an <code>array</code> to a <code>For Loop</code> or
      <code>While Loop</code> input tunnel, you can read and process
      every element in that <code>array</code> by enabling
      auto-indexing. When you auto-index an <code>array</code> output
      tunnel, the output <code>array</code> receives a new element
      from every iteration of the loop. The wire from the <code>output
      tunnel</code> to the <code>array indicator</code> becomes
      thicker as it changes to an <code>array</code> at the loop
      border, and the <code>output tunnel</code> contains square
      brackets representing an <code>array</code>, as shown in <cnxn target="f1"/>.
      <figure id="f1">
	<media type="image/png" src="autoindexon.png"/>
      </figure>
    </para>
    <para id="para2">
      Disable auto-indexing by right-clicking the tunnel and selecting
      <code>Disable Indexing</code> from the shortcut menu. For
      example, disable auto-indexing if you need only the last value
      passed to the tunnel in the previous example.
    </para>
    <para id="para3">
      Because you can use <code>For Loops</code> to process
      <code>arrays</code> an element at a time, LabVIEW enables
      auto-indexing by default for every <code>array</code> you wire
      to a <code>For Loop</code> and for each output tunnel that is
      created. Auto-indexing for <code>While Loops</code> is disabled
      by default. To enable auto-indexing, right-click a tunnel and
      select <code>Enable Indexing</code> from the shortcut menu.
    </para>
    <section id="section1">
      <name>Creating Two-Dimensional Arrays</name>
      <para id="para4">
	You can use two <code>For Loops</code>, one inside the other,
	to create a 2-D <code>array</code>. The outer <code>For
	Loop</code> creates the row elements, and the inner <code>For
	Loop</code> creates the column elements, as shown in <cnxn target="f2"/>.
	<figure id="f2">
	  <media type="image/png" src="2darrayforloop.png"/>
	</figure>
      </para>
    </section>
    <section id="section2">
      <name>Using Auto-Indexing to Set the For Loop Count</name>
      <para id="para5">
	If you enable auto-indexing on an <code>array</code> wired to
	a <code>For Loop</code> input terminal, LabVIEW sets the
	<code>count</code> terminal to the array size so you do not
	need to wire the <code>count</code> terminal.
      </para>
      <para id="para6">
	In <cnxn target="f3"/>, the <code>For Loop</code> executes a
	number of times equal to the number of elements in the
	<code>array</code>. Normally, if the <code>count</code>
	terminal of the <code>For Loop</code> is not wired, the run
	arrow is broken. However, in this case the run arrow is not
	broken.
	<figure id="f3">
	  <media type="image/png" src="autoindexinput.png"/>
	</figure>
      </para>
      <para id="para7">
	If you enable auto-indexing for more than one tunnel or if you
	wire the <code>count</code> terminal, the count changes to the
	smaller of the two. For example, if you wire an
	<code>array</code> with
	<m:math>
	  <m:cn>10</m:cn>
	</m:math>
	elements to a <code>For Loop</code> input tunnel and you set
	the <code>count</code> terminal to
	<m:math>
	  <m:cn>15</m:cn>
	</m:math>,
	the loop executes only
	<m:math>
	  <m:cn>10</m:cn>
	</m:math> times.
      </para>
    </section>
  </content>
  
</document>
