GlobalList (PersistentObjectInfo function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
Line 14: Line 14:
==Usage notes==
==Usage notes==
==Examples==
==Examples==
The following statement sorts by setting time the contents of the <var>Arraylist</var> returned by <var>GlobalList</var>:
<ol>
  <p class="code">%persInfoList = %(object):globalList:sortNew(descending(setTime))</p>
<li>In the following example, <var>GlobalList</var> is invoked with no explicit parameter:
<p class="code">b                                                                                                   
%i is float                                                                                         
%persInfoList    is arraylist of object persistentObjectInfo                                                 
%sl is object stringlist                                                               
%sl2 is object stringlist
 
%sl = list('alpha', 'beta', 'ceta')
%sl2 = list('one', 'two', 'three')                               
         
%(Object):SetGlobal('ABC', %sl)
%(Object):SetGlobal('NUM', %sl2)                                       
           
%persInfoList = %(Object):globalList
for %i from 1 to %persInfoList:count                                                                 
  printText *** {~} = {%i}, {~} = {%persInfoList(%i):name}, {~} = {%persInfoList(%i):classDescription}
end for
end
</p>
 
The result, assuming no globals have been set prior to this request, is:
<p class="output">%i = 1, %persInfoList(%i):name = ABC, %persInfo:classDescription = System:Stringlist
%i = 2, %persInfoList(%i):name = NUM, %persInfo:classDescription = System:Stringlist
</p>
 
<li>The following statement uses the <var>[[Name (PersistentObjectInfo function)|Name]]</var> method to sort by name the contents of the <var>Arraylist</var> returned by <var>GlobalList</var>:
  <p class="code">%persInfoList = %(object):globalList:sortNew(descending(name))</p>
Applied to the <code>%persInfoList</code> in the preceding example, the result is:
<p class="output">%i = 1, %persInfoList(%i):name = NUM, %persInfoList(%i):classDescription = System:Stringlist 
%i = 2, %persInfoList(%i):name = ABC, %persInfoList(%i):classDescription = System:Stringlist
</p>
</ol>


==See also==
==See also==
{{Template:PersistentObjectInfo:GlobalList footer}}
{{Template:PersistentObjectInfo:GlobalList footer}}

Revision as of 15:40, 19 August 2011

Get list of global objects (PersistentObjectInfo class)

[Introduced in Sirius Mods 7.8]


Syntax

%persObjList = %(PersistentObjectInfo):GlobalList[( [matchString])]

Syntax terms

%persObjListAn Arraylist of Object PersistentObjectInfo object variable.
(PersistentObjectInfo) The class name in parentheses denotes a shared method. GlobalList can also be invoked via a PersistentObjectInfo object variable, which may be Null.
matchString An optional, case-sensitive, pattern-matching string that identifies the name(s) of the global(s) whose information is to be returned to %persObjList. The default if no string is provided is to return information of all global objects.

Usage notes

Examples

  1. In the following example, GlobalList is invoked with no explicit parameter:

    b %i is float %persInfoList is arraylist of object persistentObjectInfo %sl is object stringlist %sl2 is object stringlist %sl = list('alpha', 'beta', 'ceta') %sl2 = list('one', 'two', 'three') %(Object):SetGlobal('ABC', %sl) %(Object):SetGlobal('NUM', %sl2) %persInfoList = %(Object):globalList for %i from 1 to %persInfoList:count printText *** {~} = {%i}, {~} = {%persInfoList(%i):name}, {~} = {%persInfoList(%i):classDescription} end for end

    The result, assuming no globals have been set prior to this request, is:

    %i = 1, %persInfoList(%i):name = ABC, %persInfo:classDescription = System:Stringlist %i = 2, %persInfoList(%i):name = NUM, %persInfo:classDescription = System:Stringlist

  2. The following statement uses the Name method to sort by name the contents of the Arraylist returned by GlobalList:

    %persInfoList = %(object):globalList:sortNew(descending(name))

    Applied to the %persInfoList in the preceding example, the result is:

    %i = 1, %persInfoList(%i):name = NUM, %persInfoList(%i):classDescription = System:Stringlist %i = 2, %persInfoList(%i):name = ABC, %persInfoList(%i):classDescription = System:Stringlist

See also