MoveFromId (Stringlist subroutine): Difference between revisions

From m204wiki
Jump to navigation Jump to search
Line 17: Line 17:


==Examples==
==Examples==
<ol><li>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:
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 28: Line 28:
</p>
</p>


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.</ol>
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.


==See also==
==See also==
<ul><li><var>[[MoveToId (Stringlist subroutine)|MoveToId]]</var> which does the converse (move <var>Stringlist</var> data into a <var>$list</var>)</ul>
<ul><li><var>[[MoveToId (Stringlist subroutine)|MoveToId]]</var> which does the converse (move <var>Stringlist</var> data into a <var>$list</var>)</ul>
{{Template:Stringlist:MoveFromId footer}}
{{Template:Stringlist:MoveFromId footer}}

Revision as of 21:50, 11 April 2012

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 MovefromId is invoked, the source $list will be emptied, although the $list identifier is still valid.
  • MoveFromId discards any current 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.

See also

  • MoveToId which does the converse (move Stringlist data into a $list)