$ListInfI: Difference between revisions
(Automatically generated page update) |
|||
(3 intermediate revisions by 2 users not shown) | |||
Line 2: | Line 2: | ||
<span class="pageSubtitle">Retrieve $list item into image</span> | <span class="pageSubtitle">Retrieve $list item into image</span> | ||
<p class="warn"><b>Note: </b> | <p class="warn"><b>Note:</b> Many $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the <var>$ListInfI</var> function is <var>[[GetImage (Stringlist subroutine)|GetImage]]</var>. </p> | ||
This function copies data from a specified $list item to an image. | This function copies data from a specified $list item to an image. | ||
Line 8: | Line 8: | ||
The <var>$ListInfI</var> function accepts three arguments and returns a numeric result. It is a [[Calling Sirius Mods $functions|callable]] $function. | The <var>$ListInfI</var> function accepts three arguments and returns a numeric result. It is a [[Calling Sirius Mods $functions|callable]] $function. | ||
==Syntax== | |||
<p class="syntax">[%result =] $ListInfI(list_identifier, item_num, image_id) | |||
</p> | |||
<table> | |||
<tr><th>%result</th> | |||
<td>A number that indicates whether or not an error has occurred. See [[#Return codes|Return codes]], below. </td></tr> | |||
<tr><th>list_identifier</th> | |||
<td>A $list identifier. This is a required argument. </td></tr> | |||
<tr><th>item_num</th> | |||
< | <td>The number of the item in the <var class="term">list_identifier</var> $list. This is a required argument. </td></tr> | ||
</ | |||
<p><var | <tr><th>image_id</th> | ||
<td>A string containing the name of an image (or, as shown below in the "Usage notes" section, an identifier of an image item from the image). | |||
<p> | |||
This is an optional argument if an image is associated with the $list by a <var>[[$ListImg]]</var> function. Otherwise, it is a required argument. </p></td></tr> | |||
</table> | |||
=== | ===Return codes=== | ||
<p class="code"> 0 - Data successfully copied | <p class="code"> 0 - Data successfully copied | ||
-5 - Required argument not specified | -5 - Required argument not specified | ||
Line 29: | Line 37: | ||
==Usage notes== | ==Usage notes== | ||
One way to extract a $list item into an image called <code>HEADSTONE</code> is as follows: | |||
<p class="code">% | <p class="code">%rc = $ListInfI(%list, %n, 'HEADSTONE') </p> | ||
<p> | |||
This is a more efficient way: | |||
</p> | </p> | ||
<p class="code">%rc = $ListInfI(%list, %n, %HEADSTONE:ID) | |||
<p class="code">% | |||
</p> | </p> | ||
<p> | |||
The specific image item is irrelevant (as long as it is valid) in this call, but is more efficient than specifying the image name | The specific image item is irrelevant (as long as it is valid) in this call, but is more efficient than specifying the quoted image name: In the first example, the image name must be hashed and looked up (in NTBL) in each invocation of <var>$ListInfI</var>, while in the second example, the hashing of the image name and lookup happens only once, and that is at compile time. </p> | ||
<p> | <p> | ||
Here is an even neater and equally efficient way of coding this: </p> | Here is an even neater and equally efficient way of coding this: </p> | ||
<p class="code">% | <p class="code">%rc = $ListImg(%list, %HEADSTONE:FNAME) | ||
. . . | . . . | ||
% | %rc = $ListInfI(%list, %n) </p> | ||
<p> | |||
In this last example, <var>[[$ListImg]]</var> associates the image with the $list, eliminating the need to specify the image name on the <var>$ListInfI</var>. This association is also useful in many other function calls by providing a structure to be associated with the $list that is useful for column-oriented functions such as <var>[[$ListFindI and $ListFindI_Up|$ListFindI]]</var> and <var>[[$ListSort and $ListSrt|$ListSrt]]</var>. </p> | |||
<p> | |||
<b>NOTE:</b> <var>[[$lists]]</var> items shorter than the target image do not modify the image contents beyond the <var>[[$lists]]</var> item length. As such, if <var>[[$ListInfI]]</var> is used with varying length Stringlist items, the images can contain "leftover" data after a <var>[[$ListInfI]]</var>. If this is a concern, a Prepare Image should be done before each <var>[[$ListInfI]]</var> invocation. | |||
</p> | </p> | ||
==Products authorizing {{PAGENAMEE}}== | ==Products authorizing {{PAGENAMEE}}== | ||
<ul class="smallAndTightList"> | <ul class="smallAndTightList"> | ||
<li>[[ | <li>[[Sirius Functions]]</li> | ||
<li>[[Fast/Unload User Language Interface]]</li> | <li>[[Fast/Unload User Language Interface]]</li> | ||
<li>[[Media:JoclrNew.pdf|Janus Open Client]]</li> | <li>[[Media:JoclrNew.pdf|Janus Open Client]]</li> |
Latest revision as of 17:52, 11 January 2022
Retrieve $list item into image
Note: Many $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $ListInfI function is GetImage.
This function copies data from a specified $list item to an image.
The $ListInfI function accepts three arguments and returns a numeric result. It is a callable $function.
Syntax
[%result =] $ListInfI(list_identifier, item_num, image_id)
%result | A number that indicates whether or not an error has occurred. See Return codes, below. |
---|---|
list_identifier | A $list identifier. This is a required argument. |
item_num | The number of the item in the list_identifier $list. This is a required argument. |
image_id | A string containing the name of an image (or, as shown below in the "Usage notes" section, an identifier of an image item from the image).
This is an optional argument if an image is associated with the $list by a $ListImg function. Otherwise, it is a required argument. |
Return codes
0 - Data successfully copied -5 - Required argument not specified -6 - $List identifier invalid -7 - Item number not found in $list -8 - Image not found or not active
Usage notes
One way to extract a $list item into an image called HEADSTONE
is as follows:
%rc = $ListInfI(%list, %n, 'HEADSTONE')
This is a more efficient way:
%rc = $ListInfI(%list, %n, %HEADSTONE:ID)
The specific image item is irrelevant (as long as it is valid) in this call, but is more efficient than specifying the quoted image name: In the first example, the image name must be hashed and looked up (in NTBL) in each invocation of $ListInfI, while in the second example, the hashing of the image name and lookup happens only once, and that is at compile time.
Here is an even neater and equally efficient way of coding this:
%rc = $ListImg(%list, %HEADSTONE:FNAME) . . . %rc = $ListInfI(%list, %n)
In this last example, $ListImg associates the image with the $list, eliminating the need to specify the image name on the $ListInfI. This association is also useful in many other function calls by providing a structure to be associated with the $list that is useful for column-oriented functions such as $ListFindI and $ListSrt.
NOTE: $lists items shorter than the target image do not modify the image contents beyond the $lists item length. As such, if $ListInfI is used with varying length Stringlist items, the images can contain "leftover" data after a $ListInfI. If this is a concern, a Prepare Image should be done before each $ListInfI invocation.