<doc>
  <legacy_id>2197</legacy_id>
  <name>each</name>
  <type>keyword</type>
  <syntax>
  </syntax>
  <library></library>
  <objects>
  </objects>
  <synonyms>
  </synonyms>
  <classification>
    <category>Writing LiveCode</category>
    <category>Text and Data Processing</category>
  </classification>
  <references>
    <command tag="sort container">sort container Command</command>
    <keyword tag="element">element Keyword</keyword>
    <control_st tag="repeat">repeat Control Structure</control_st>
  </references>
  <history>
    <introduced version="1.0">Added.</introduced>
    <changed version="1.1"></changed>
  </history>
  <platforms>
    <mac/>
    <windows/>
    <linux/>
    <ios/>
    <android/>
  </platforms>
  <classes>
    <desktop/>
    <server/>
    <web/>
    <mobile/>
  </classes>
  <security>
  </security>
  <summary>Used with the <command tag="sort container">sort container</command> <glossary tag="command">command</glossary> to specify that the <glossary tag="sort key">sort key</glossary> consists of the specified <glossary tag="chunk">chunk</glossary> of each <keyword tag="line">line</keyword> or <keyword tag="item">item</keyword>. Also used with the <keyword tag="for">for</keyword> <glossary tag="keyword">keyword</glossary> in a <control_st tag="repeat">repeat</control_st> <glossary tag="control structure">control structure</glossary> to specify that the <glossary tag="loop">repeat loop</glossary> should be executed for each <glossary tag="chunk">chunk</glossary> of the specified <keyword tag="string">string</keyword> or each <keyword tag="element">element</keyword> of the specified <glossary tag="array">array</glossary>.</summary>
  <examples>
    <example>sort lines of field "Address" by word 2 of each</example>
    <example>repeat for each character thisChar in field "Input"</example>
  </examples>
  <description>
    <p>Use the <b>each</b> <glossary tag="keyword">keyword</glossary> to <command tag="sort">sort</command> a <glossary tag="container">container</glossary> by a portion of each <keyword tag="item">item</keyword> or <keyword tag="line">line</keyword>, rather than by the whole <keyword tag="item">item</keyword> or <keyword tag="line">line</keyword>, or to <glossary tag="iteration">iterate</glossary> over each <glossary tag="chunk">chunk</glossary> in a <keyword tag="string">string</keyword> or each <keyword tag="element">element</keyword> in an <glossary tag="array">array</glossary>.</p><p/><p><b>Comments:</b></p><p>In a <b>sort container</b> <glossary tag="command">command</glossary>, the expression before "<code>of each</code>" must be a chunk expression. The <glossary tag="chunk expression">chunk expression</glossary> describes a portion of each <keyword tag="item">item</keyword> or <keyword tag="line">line</keyword> in the <glossary tag="container">container</glossary> to be <glossary tag="sort">sorted</glossary>.</p><p/><p>If a chunk is nonexistent for a particular line or item--for example, if "<code>by char 5 of each</code>" is specified and some lines only have four characters--the chunk is treated as though it were empty.</p><p/><p><b>Changes:</b></p><p>The ability to specify each element of an array in a <b>repeat</b> <glossary tag="control structure">control structure</glossary> was introduced in version 1.1. In previous versions, you could use the <b>each</b> <glossary tag="keyword">keyword</glossary> to <glossary tag="iteration">iterate</glossary> over all <glossary tag="chunk">chunks</glossary> in a <keyword tag="string">string</keyword>, but not over all <glossary tag="element">elements</glossary> in an <glossary tag="array">array</glossary>.</p>
  </description>
</doc>