GlobalList (PersistentObjectInfo function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
 
(7 intermediate revisions by 3 users not shown)
Line 6: Line 6:
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%persObjList</th><td>An <var>Arraylist of Object PersistentObjectInfo</var> object variable.</td></tr>
<tr><th>%persObjList</th><td>An <var>Arraylist of Object PersistentObjectInfo</var> object variable.</td></tr>
<tr><th><var>(PersistentObjectInfo)</var></th>
<tr><th><var class="nobr">%(PersistentObjectInfo)</var></th>
<td>The class name in parentheses denotes a [[Notation conventions for methods#Shared members|shared]] method. <var>GlobalList</var> can also be invoked via a <var>PersistentObjectInfo</var> object variable, which may be <var>Null</var>.</td></tr>
<td>The class name in parentheses denotes a [[Notation conventions for methods#Shared methods|shared]] method. <var>GlobalList</var> can also be invoked via a <var>PersistentObjectInfo</var> object variable, which may be <var>Null</var>.</td></tr>
<tr><th>matchString</th>
<tr><th>matchString</th>
<td>An optional, case-sensitive, pattern-matching string that identifies the name(s) of the global(s) whose information is to be returned to <var class="term">%persObjList</var>. The default if no string is provided is to return information of all global objects.</td></tr>
<td>An optional, case-sensitive, pattern-matching string that identifies the name(s) of the global(s) whose information is to be returned to <var class="term">%persObjList</var>. The default if no string is provided is to return information of all global objects.</td></tr>
Line 14: Line 14:
==Usage notes==
==Usage notes==
<ul>
<ul>
<li><var>GlobalList</var>is also a shared method in the <var>[[Object class|Object]]</var> class. This means that both of these statements are valid:
<li><var>GlobalList</var> is also a shared method in the <var>[[Object class|Object]]</var> class. This means that both of these statements are valid:
   
   
<p class="code">%persInfoList = %(persistentObjectInfo):globalList
<p class="code">%persInfoList = %(persistentObjectInfo):globalList
Line 20: Line 20:
%persInfoList = %(object):globalList</p>
%persInfoList = %(object):globalList</p>
   
   
<li>As a coding convenience, the <var>PersistentObjectInfoList</var>
type is defined as an "Arraylist of Object PersistentObjectInfo". Consequently, instead of a declaration like this one:
<p class="code">%persInfoList is arraylist of object persistentObjectInfo </p>
You can simply specify:
<p class="code">%persInfoList is type persistentObjectInfoList</p>
<p class="note">'''Note:''' The keyword <var>Type</var> is required. </p>
</ul>
</ul>


Line 25: Line 33:
<ol>
<ol>
<li>In the following example, <var>GlobalList</var> is invoked with no explicit parameter:
<li>In the following example, <var>GlobalList</var> is invoked with no explicit parameter:
<p class="code">b                                                                                                  
<p class="code">b            
%i is float                                                                                        
%i is float  
%persInfoList    is arraylist of object persistentObjectInfo                                                
%persInfoList    is arraylist of object persistentObjectInfo
%sl is object stringlist                                                              
%sl is object stringlist  
%sl2 is object stringlist  
%sl2 is object stringlist  


Line 35: Line 43:
            
            
%(Object):SetGlobal('ABC', %sl)  
%(Object):SetGlobal('ABC', %sl)  
%(Object):SetGlobal('NUM', %sl2)                                      
%(Object):SetGlobal('NUM', %sl2)
           
 
%persInfoList = %(Object):globalList
%persInfoList = %(persistentObjectInfo):globalList
for %i from 1 to %persInfoList:count                                                                  
for %i from 1 to %persInfoList:count  
   printText *** {~} = {%i}, {~} = {%persInfoList(%i):name}, {~} = {%persInfoList(%i):classDescription}
   printText *** {~} = {%i}, {~} = {%persInfoList(%i):name}, {~} = {%persInfoList(%i):classDescription}
end for  
end for  
Line 50: Line 58:


<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>:
<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>
 
<p class="code">%persInfoList = %(persistentObjectInfo):globalList:sortNew(descending(name))</p>
Applied to the <code>%persInfoList</code> in the preceding example, the result is:
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   
<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
%i = 2, %persInfoList(%i):name = ABC, %persInfoList(%i):classDescription = System:Stringlist
</p>
</p>
As stated in the "Usage notes" above, <var>GlobalList</var> is also a member of the <var>Object</var> class. The <var>SortNew</var> statement in this example could also be specified as follows to get the same result:
<p class="output">%persInfoList = %(Object):globalList:sortNew(descending(name))</p>
</ol>
</ol>


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

Latest revision as of 20:55, 12 August 2014

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

  • GlobalList is also a shared method in the Object class. This means that both of these statements are valid:

    %persInfoList = %(persistentObjectInfo):globalList %persInfoList = %(object):globalList

  • As a coding convenience, the PersistentObjectInfoList type is defined as an "Arraylist of Object PersistentObjectInfo". Consequently, instead of a declaration like this one:

    %persInfoList is arraylist of object persistentObjectInfo

    You can simply specify:

    %persInfoList is type persistentObjectInfoList

    Note: The keyword Type is required.

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 = %(persistentObjectInfo):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 = %(persistentObjectInfo):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

    As stated in the "Usage notes" above, GlobalList is also a member of the Object class. The SortNew statement in this example could also be specified as follows to get the same result:

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

See also