Item (Stringlist function): Difference between revisions
m (camelCase) |
m (better tagging each time thru) |
||
Line 20: | Line 20: | ||
<ul> | <ul> | ||
<li>All errors in <var>Item</var> result in request cancellation. | <li>All errors in <var>Item</var> result in request cancellation. | ||
<li>Unlike the <var>[[Item (Arraylist property)|Item]]</var> method for <var>collections</var>, the <var>Item</var> method for <var>stringlists</var> is not settable. To set a new value for a <var>stringlist</var> item, use [[Replace (Stringlist function)|Replace]]. | <li>Unlike the <var>[[Item (Arraylist property)|Item]]</var> method for <var>collections</var>, the <var>Item</var> method for <var>stringlists</var> is not settable. To set a new value for a <var>stringlist</var> item, use [[Replace (Stringlist function)|Replace]].</ul> | ||
==Examples== | ==Examples== | ||
Line 43: | Line 43: | ||
==See also== | ==See also== | ||
There are optimized methods available to retrieve just the first or just the last item in a <var>Stringlist</var>. See also:<ul><li><var>[[FirstItem (Stringlist function)|FirstItem]]</var> and / or<li><var>[[LastItem (Stringlist function)|LastItem]]</var>.</ul> | |||
{{Template:Stringlist:Item footer}} | {{Template:Stringlist:Item footer}} |
Revision as of 02:25, 27 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, the Item method for stringlists is not settable. To set a new value for a stringlist item, use Replace.
Examples
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
See also
There are optimized methods available to retrieve just the first or just the last item in a Stringlist. See also: