<doc>
  <legacy_id>2467</legacy_id>
  <name>param</name>
  <type>function</type>
  <syntax>
    <example>the param of <i>parameterNumber</i></example>
    <example>param(<i>parameterNumber</i>)</example>
  </syntax>
  <library></library>
  <objects>
  </objects>
  <synonyms>
  </synonyms>
  <classification>
    <category>Writing LiveCode</category>
    <category>Values &amp; Properties</category>
  </classification>
  <references>
    <function tag="paramCount">paramCount Function</function>
    <control_st tag="function">function Control Structure</control_st>
  </references>
  <history>
    <introduced version="1.0">Added.</introduced>
  </history>
  <platforms>
    <mac/>
    <windows/>
    <linux/>
    <ios/>
    <android/>
  </platforms>
  <classes>
    <desktop/>
    <server/>
    <web/>
    <mobile/>
  </classes>
  <security>
  </security>
  <summary><glossary tag="return">Returns</glossary> the specified <glossary tag="parameter">parameter</glossary> <glossary tag="pass">passed</glossary> to the current <glossary tag="handler">handler</glossary>.</summary>
  <examples>
    <example>param(3) <code><i>-- returns the third parameter</i></code></example>
    <example>param(0) <code><i>-- returns the handler name</i></code></example>
  </examples>
  <description>
    <p>Use the <b>param</b> <control_st tag="function">function</control_st> within a <glossary tag="handler">handler</glossary> to get the value of a <glossary tag="parameter">parameter</glossary> when you don't know in advance how many <glossary tag="parameter">parameters</glossary> will be <glossary tag="pass">passed</glossary> to the <glossary tag="handler">handler</glossary>.</p><p/><p><b>Parameters:</b></p><p>The <i>parameterNumber</i> is a <href tag="../glossary/nondashnegative.xml">non-negative</href> <keyword tag="integer">integer</keyword>.</p><p/><p><b>Value:</b></p><p>The <b>param</b> <control_st tag="function">function</control_st> <glossary tag="return">returns</glossary> the <glossary tag="parameter">parameter</glossary> value specified by the <i>parameterNumber</i>. If the <i>parameterNumber</i> is zero, the <b>param</b> <control_st tag="function">function</control_st> <glossary tag="return">returns</glossary> the <glossary tag="handler">handler</glossary> name.</p><p/><p><b>Comments:</b></p><p>Usually, you assign names to parameters in the first line of a function handler or message handler. For example, the following function assigns three parameters, which are multiplied together:</p><p/><p><code>  function product firstFactor,secondFactor,thirdFactor</code></p><p><code>    return firstFactor * secondFactor * thirdFactor</code></p><p><code>  end product</code></p><p/><p>But if you want to multiply all the numbers passed to the function handler together, you don't know ahead of time how many parameters will be passed, so you can't assign a parameter name (such as<code> firstFactor</code>) to each one in the first line of the function handler. In this case, you can use the <b>param</b> <control_st tag="function">function</control_st> to use each <glossary tag="parameter">parameter</glossary> without needing to assign it a name:</p><p/><p><code>  function product</code></p><p><code>    put 1 into total</code></p><p><code>    repeat with nextFactor = 1 to the paramCount</code></p><p><code/>      multiply total by param(nextFactor)</p><p><code>    end repeat</code></p><p><code>    return total</code></p><p><code>  end product</code></p><p/><p>LiveCode evaluates the parameters before passing them. So if you call<code> myHandler </code>with the following statement:</p><p><code>  myHandler 1+1,"A","Hello" &amp;&amp; "world"</code></p><p>the parameters returned by the <b>param</b> <control_st tag="function">function</control_st> are<code> 2</code><a/>,<code> A</code>, and "<code>Hello World</code>".</p>
  </description>
</doc>