MoveFromId (Stringlist subroutine): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (syntax digram, tags and links)
Line 1: Line 1:
{{Template:Stringlist:MoveFromId subtitle}}
{{Template:Stringlist:MoveFromId subtitle}}


This method moves data ($list items) from a $list to a <var>Stringlist</var>. <var>MoveFromId</var> is a subroutine that accepts one argument: the $list identifier of the $list from which data is to be moved. For more information about $list identifiers, see the ''Sirius Functions Reference Manual''.
This method moves data (<var>$list</var> items) from a <var>$list</var> to a <var>stringlist</var>. <var>MoveFromId</var> is a subroutine that accepts one argument: the <var>$list</var> identifier of the <var>$list</var> from which data is to be moved. For more information about <var>$list</var> identifiers, see the <var class="Product">[[Sirius Functions Reference Manual]]</var>.


==Syntax==
==Syntax==
Line 10: Line 10:
<td>A <var>Stringlist</var> object.</td></tr>
<td>A <var>Stringlist</var> object.</td></tr>
<tr><th>listid</th>
<tr><th>listid</th>
<td>The $list identifier of the $list from which data is to be moved.</td></tr>
<td>The <var>$list</var> identifier of the $list from which data is to be moved.</td></tr>
</table>
</table>


==Usage notes==
==Usage notes==
<ul><li>All errors in <var>MoveFromId</var> result in request cancellation.<li>After the MovefromId method is invoked, the source $list is empty, though the $list identifier is still valid.<li><var>MoveFromId</var> discards the original contents of the method <var>Stringlist</var>.<li>The <var>MoveFromId</var> method copies to the method <var>Stringlist</var> any image association that is set via $listimg.<li>MoveFromid simply moves the pointers to the $list data to the object <var>Stringlist</var>. It does '''not''' actually perform any data movement; therefore, it is extremely efficient.<li>MoveFromid is intended to facilitate migration to <var>Stringlist</var>s of existing applications that use $lists. For example, suppose complex subroutine Summarize takes a $list identifier as its input parameter. Further suppose that the subroutine is rewritten to use <var>Stringlist</var>s rather than $lists.
<ul><li>All errors in <var>MoveFromId</var> result in request cancellation.<li>After the <var>MovefromId</var> is invoked, the source <var>$list</var> is empty, although the <var>$list</var> identifier is still valid.<li><var>MoveFromId</var> discards the original contents of the method <var>stringlist</var>.<li><var>MoveFromId</var> copies to the method <var>stringlist</var> any image association that is set via <var>$listimg</var>.<li><var>MoveFromid</var> simply moves the internal <var>$list</var> data pointers to the object <var>stringlist</var>. It does '''not''' actually perform any data movement; therefore, it is extremely efficient.<li><var>MoveFromid</var> is intended to facilitate migration to <var>stringlist</var>s of existing applications that use <var>$lists</var>.<li> <var>stringlists</var> should always be used in preference to <var>$lists</var>, so <var>MoveFromId</var> is provided only for the migration of existing <var>$list</var> applications to the use of <var>Stringlist</var>s.</ul>
The following code illustrates how this can be accomplished:
 
==Examples==
Suppose complex subroutine Summarize takes a <var>$list</var> identifier as its input parameter. Further suppose that the subroutine is rewritten to use <var>Stringlist</var>s rather than <var>$list</var>. The following code illustrates how this can be accomplished:


<p class="code">subroutine summarize(%listId is float)
<p class="code">subroutine summarize(%listId is float)
Line 21: Line 23:
%list = new
%list = new
%list:moveFromid(%listId)
%list:moveFromid(%listId)
...
  ...
%list:moveToid(%listId)
%list:moveToid(%listId)
return
return
</p>
</p>


Of course, if the subroutine "forgets" to restore the input $list contents with MoveToId, the input $list remains empty at the end of the subroutine. <var>Stringlist</var>s should always be used in preference to $lists, so <var>MoveFromId</var> is provided only for the migration of existing $list applications to the use of <var>Stringlist</var>s.
Of course, if the subroutine "forgets" to restore the input <var>$list</var> contents with <var>MoveToId</var>, the input <var>$list</var> remains empty at the end of the subroutine.
</ul>


[[Category:Stringlist methods|MoveFromId subroutine]]
[[Category:Stringlist methods|MoveFromId subroutine]]

Revision as of 08:32, 26 January 2011

Move data from $list to Stringlist (Stringlist class)


This method moves data ($list items) from a $list to a stringlist. MoveFromId is a subroutine that accepts one argument: the $list identifier of the $list from which data is to be moved. For more information about $list identifiers, see the Sirius Functions Reference Manual.

Syntax

sl:MoveFromId( listId)

Syntax terms

sl A Stringlist object.
listid The $list identifier of the $list from which data is to be moved.

Usage notes

  • All errors in MoveFromId result in request cancellation.
  • After the MovefromId is invoked, the source $list is empty, although the $list identifier is still valid.
  • MoveFromId discards the original contents of the method stringlist.
  • MoveFromId copies to the method stringlist any image association that is set via $listimg.
  • MoveFromid simply moves the internal $list data pointers to the object stringlist. It does not actually perform any data movement; therefore, it is extremely efficient.
  • MoveFromid is intended to facilitate migration to stringlists of existing applications that use $lists.
  • stringlists should always be used in preference to $lists, so MoveFromId is provided only for the migration of existing $list applications to the use of Stringlists.

Examples

Suppose complex subroutine Summarize takes a $list identifier as its input parameter. Further suppose that the subroutine is rewritten to use Stringlists rather than $list. The following code illustrates how this can be accomplished:

subroutine summarize(%listId is float) %list is object stringList %list = new %list:moveFromid(%listId) ... %list:moveToid(%listId) return

Of course, if the subroutine "forgets" to restore the input $list contents with MoveToId, the input $list remains empty at the end of the subroutine.