Item (Stringlist function): Difference between revisions
Jump to navigation
Jump to search
m (1 revision) |
m (1 revision) |
||
Line 1: | Line 1: | ||
{{Template:Stringlist:Item subtitle}} | {{Template:Stringlist:Item subtitle}} | ||
This method returns the current contents of a specified Stringlist item. The Item method accepts one argument and returns a string result. | This method returns the current contents of a specified <var>Stringlist</var> item. The Item method accepts one argument and returns a string result. | ||
==Syntax== | ==Syntax== | ||
Line 10: | Line 10: | ||
<td>This longstring is to contain the contents of the '''%sl''' item. </td></tr> | <td>This longstring is to contain the contents of the '''%sl''' item. </td></tr> | ||
<tr><th>sl </th> | <tr><th>sl </th> | ||
<td>A Stringlist object. </td></tr> | <td>A <var>Stringlist</var> object. </td></tr> | ||
<tr><th>itemnum </th> | <tr><th>itemnum </th> | ||
<td>The number of the item in the '''%sl''' Stringlist.</td></tr> | <td>The number of the item in the '''%sl''' <var>Stringlist</var>.</td></tr> | ||
</table> | </table> | ||
Line 19: | Line 19: | ||
<li>All errors in Item result in request cancellation. | <li>All errors in Item result in request cancellation. | ||
<li>Unlike the Item method for collections (see [[Item (ArrayList property)]]), the Item method for Stringlists is not settable. To set a new value for a Stringlist item, use the [[Replace (Stringlist function)]]. | <li>Unlike the Item method for collections (see [[Item (ArrayList property)]]), the Item method for Stringlists is not settable. To set a new value for a Stringlist item, use the [[Replace (Stringlist function)]]. | ||
<li>The following loop uses the Item method to display the contents of a Stringlist: | <li>The following loop uses the Item method to display the contents of a <var>Stringlist</var>: | ||
<pre> | <pre> | ||
Line 33: | Line 33: | ||
</pre> | </pre> | ||
<li>Under <var class=product>Sirius Mods</var> Version 6.8 and later, the method name, <tt>.Item</tt>, is not necessary on a Stringlist Item reference. For example, the previous program with Item references could be written as: | <li>Under <var class=product>Sirius Mods</var> Version 6.8 and later, the method name, <tt>.Item</tt>, is not necessary on a <var>Stringlist</var> Item reference. For example, the previous program with Item references could be written as: | ||
<pre> | <pre> | ||
Line 41: | Line 41: | ||
</pre> | </pre> | ||
<li>Methods are available to retrieve just the first or just the last item in a Stringlist. See [[FirstItem (Stringlist function)]] and [[LastItem (Stringlist function)]]. | <li>Methods are available to retrieve just the first or just the last item in a <var>Stringlist</var>. See [[FirstItem (Stringlist function)]] and [[LastItem (Stringlist function)]]. | ||
</ul> | </ul> | ||
[[Category:Stringlist methods|Item function]] | [[Category:Stringlist methods|Item function]] |
Revision as of 21:33, 18 January 2011
Retrieve value of Stringlist item (Stringlist class)
This method returns the current contents of a specified Stringlist item. The Item method accepts one argument and returns a string result.
Syntax
%string = sl:Item( itemNum)
Syntax terms
%string | This longstring is to contain the contents of the %sl item. |
---|---|
sl | A Stringlist object. |
itemnum | The number of the item in the %sl Stringlist. |
Usage notes
- All errors in Item result in request cancellation.
- Unlike the Item method for collections (see Item (ArrayList property)), the Item method for Stringlists is not settable. To set a new value for a Stringlist item, use the Replace (Stringlist function).
- The following loop uses the Item method to display the contents of a Stringlist:
for %i from 1 to %list:count print %list:item(%i) end for
This could be accomplished much more easily with:
%list:print
- Under Sirius Mods Version 6.8 and later, the method name, .Item, is not necessary on a Stringlist Item reference. For example, the previous program with Item references could be written as:
for %i from 1 to %list:count print %list(%i) end for
- Methods are available to retrieve just the first or just the last item in a Stringlist. See FirstItem (Stringlist function) and LastItem (Stringlist function).