ChangeItemLength (Stringlist function): Difference between revisions
Jump to navigation
Jump to search
m (1 revision) |
m (1 revision) |
||
Line 1: | Line 1: | ||
{{Template:Stringlist:ChangeItemLength subtitle}} | {{Template:Stringlist:ChangeItemLength subtitle}} | ||
This callable method changes the length of a Stringlist item. ChangeItemLength is provided mainly for compatibility with $listAdj in the $list API (described in the ''Sirius Functions Reference Manual''). Except when migrating existing applications that use $lists to use | This callable method changes the length of a <var>Stringlist</var> item. ChangeItemLength is provided mainly for compatibility with $listAdj in the $list API (described in the ''Sirius Functions Reference Manual''). Except when migrating existing applications that use $lists to use <var>Stringlist</var>s, it is probably best to avoid use of ChangeItemLength. | ||
==Syntax== | ==Syntax== | ||
Line 10: | Line 10: | ||
<td>A numeric variable that is set to 0 if the new item length is the same as the old item length, 1 if it is less, or 2 if it is greater.</td></tr> | <td>A numeric variable that is set to 0 if the new item length is the same as the old item length, 1 if it is less, or 2 if it is greater.</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>A Stringlist item number.</td></tr> | <td>A <var>Stringlist</var> item number.</td></tr> | ||
<tr><th>length</th> | <tr><th>length</th> | ||
<td>A number that indicates the new length of the Stringlist item. Its minimum valid value is 0; its maximum value is 6124 under <var class=product>Sirius Mods</var> Version 6.5, and 2**31-1 under <var class=product>Sirius Mods</var> Version 6.6 and later. If this value is smaller than the current length of the Stringlist item, the Stringlist item is truncated. If this value is larger than the current length of the Stringlist item, the Stringlist item is padded with blanks to the indicated length.</td></tr> | <td>A number that indicates the new length of the <var>Stringlist</var> item. Its minimum valid value is 0; its maximum value is 6124 under <var class=product>Sirius Mods</var> Version 6.5, and 2**31-1 under <var class=product>Sirius Mods</var> Version 6.6 and later. If this value is smaller than the current length of the <var>Stringlist</var> item, the <var>Stringlist</var> item is truncated. If this value is larger than the current length of the <var>Stringlist</var> item, the <var>Stringlist</var> item is padded with blanks to the indicated length.</td></tr> | ||
</table> | </table> | ||
==Usage notes== | ==Usage notes== | ||
<ul><li>All errors in ChangeItemLength result in request cancellation.<li>ChangeItemLength is extremely efficient if the Stringlist item size is not being changed (return value for ChangeItemLength of 0), fairly efficient when a Stringlist item is being shortened (return value of 1), and can be fairly expensive when a Stringlist item is being lengthened (return value of 2). Increasing the length of a Stringlist item can be expensive, because such a ChangeItemLength can result in the splitting of a Stringlist leaf page. Once a leaf page is split, it will not be merged back together, even if subsequent RemoveItems (or ChangeItemLengths) make this possible. Because of this splitting, heavy use of ChangeItemLength invocations (and Insert and RemoveItem) that increase Stringlist item size has two potentially adverse consequences:<ul><li>It can result in "sparse" | <ul><li>All errors in ChangeItemLength result in request cancellation.<li>ChangeItemLength is extremely efficient if the <var>Stringlist</var> item size is not being changed (return value for ChangeItemLength of 0), fairly efficient when a <var>Stringlist</var> item is being shortened (return value of 1), and can be fairly expensive when a <var>Stringlist</var> item is being lengthened (return value of 2). Increasing the length of a <var>Stringlist</var> item can be expensive, because such a ChangeItemLength can result in the splitting of a <var>Stringlist</var> leaf page. Once a leaf page is split, it will not be merged back together, even if subsequent RemoveItems (or ChangeItemLengths) make this possible. Because of this splitting, heavy use of ChangeItemLength invocations (and Insert and RemoveItem) that increase <var>Stringlist</var> item size has two potentially adverse consequences:<ul><li>It can result in "sparse" <var>Stringlist</var>s which place an unnecessary burden on the buffer pool and CCATEMP.<li>It can also result in an inability to add an item to the end of the <var>Stringlist</var> (via Add) because of a full pointer page, even though the <var>Stringlist</var> is nowhere near the theoretical capacity for a <var>Stringlist</var>.</ul> <var>Stringlist</var> compression can be achieved using the [[CopyItems (Stringlist function)]].</ul> | ||
==Examples== | ==Examples== | ||
The following example illustrates how ChangeItemLength (and Overlay) can be used to add an asterisk to the end of a Stringlist item. | The following example illustrates how ChangeItemLength (and Overlay) can be used to add an asterisk to the end of a <var>Stringlist</var> item. | ||
<pre> | <pre> | ||
%len = %list:ItemLength(%num) | %len = %list:ItemLength(%num) |
Revision as of 21:33, 18 January 2011
Change length of Stringlist item (Stringlist class)
This callable method changes the length of a Stringlist item. ChangeItemLength is provided mainly for compatibility with $listAdj in the $list API (described in the Sirius Functions Reference Manual). Except when migrating existing applications that use $lists to use Stringlists, it is probably best to avoid use of ChangeItemLength.
Syntax
[%rc =] sl:ChangeItemLength( itemNum, length)
Syntax terms
%rc | A numeric variable that is set to 0 if the new item length is the same as the old item length, 1 if it is less, or 2 if it is greater. |
---|---|
sl | A Stringlist object. |
itemnum | A Stringlist item number. |
length | A number that indicates the new length of the Stringlist item. Its minimum valid value is 0; its maximum value is 6124 under Sirius Mods Version 6.5, and 2**31-1 under Sirius Mods Version 6.6 and later. If this value is smaller than the current length of the Stringlist item, the Stringlist item is truncated. If this value is larger than the current length of the Stringlist item, the Stringlist item is padded with blanks to the indicated length. |
Usage notes
- All errors in ChangeItemLength result in request cancellation.
- ChangeItemLength is extremely efficient if the Stringlist item size is not being changed (return value for ChangeItemLength of 0), fairly efficient when a Stringlist item is being shortened (return value of 1), and can be fairly expensive when a Stringlist item is being lengthened (return value of 2). Increasing the length of a Stringlist item can be expensive, because such a ChangeItemLength can result in the splitting of a Stringlist leaf page. Once a leaf page is split, it will not be merged back together, even if subsequent RemoveItems (or ChangeItemLengths) make this possible. Because of this splitting, heavy use of ChangeItemLength invocations (and Insert and RemoveItem) that increase Stringlist item size has two potentially adverse consequences:
- It can result in "sparse" Stringlists which place an unnecessary burden on the buffer pool and CCATEMP.
- It can also result in an inability to add an item to the end of the Stringlist (via Add) because of a full pointer page, even though the Stringlist is nowhere near the theoretical capacity for a Stringlist.
Examples
The following example illustrates how ChangeItemLength (and Overlay) can be used to add an asterisk to the end of a Stringlist item.
%len = %list:ItemLength(%num) %list:ChangeItemLength(%num, %len + 1) %list:Overlay(%num, %len + 1, '*')
Of course, this same end can be accomplished with the Item Stringlist function) and Replace (Stringlist function).