ProcedureInfo class: Difference between revisions
m (→Example) |
m (→Example) |
||
Line 90: | Line 90: | ||
end | end | ||
</p> | </p> | ||
The result | The result looks like this: | ||
%procList:count = 7 | |||
SIRIUS 04000773 SSLP-REQ 30846 ALAN 2011071509461684 | SIRIUS 04000773 SSLP-REQ 30846 ALAN 2011071509461684 | ||
SIRIUS 0400076E SSLP-PROCS 25888 ALAN 2011071509461681 | SIRIUS 0400076E SSLP-PROCS 25888 ALAN 2011071509461681 | ||
SIRIUS 04000593 SSLP-SIGN 22908 ALAN 2008062010244706 | SIRIUS 04000593 SSLP-SIGN 22908 ALAN 2008062010244706 | ||
SIRIUS 04000259 SSLP-RECV 25827 ALAN 2008062010244218 | SIRIUS 04000259 SSLP-RECV 25827 ALAN 2008062010244218 | ||
Line 104: | Line 99: | ||
SIRIUS 04000237 SSLN-START 10115 ALAN 2008062010243273 | SIRIUS 04000237 SSLN-START 10115 ALAN 2008062010243273 | ||
SIRIUS 04000566 SSLN-END 3632 ALAN 2008062010242969 | SIRIUS 04000566 SSLN-END 3632 ALAN 2008062010242969 | ||
</p> | |||
==ProcedureInfo advantages== | ==ProcedureInfo advantages== |
Revision as of 17:02, 21 June 2012
The ProcedureInfo class provides information about the procedures in a procedure file or group. The class is an object-oriented alternative to $LSTPROC, $Proc_List, $Proc_ListG, $PrcLEx, and $PrcLExG, and it is a more structured alternative to the Stringlist class AppendProcedureList method.
ProcedureInfo objects are easily gathered into an ArrayList, so they offer the advantage of the sorting, finding, and subsetting facilities of collections.
The ProcedureInfo class is available as of Sirius Mods Version 7.8.
The information accessing methods
These pieces of information (provided by class functions named as follows) are available for an object in the ProcedureInfo class:
Bytes | The length of the procedure in bytes. |
Filename | The the name of the file that contains the procedure. |
FirstPageNumber | The internal page number of the first page of the procedure; intended for debugging. |
Name | The global/session name associated with the object. |
LastUpdateTime | The time the procedure was last updated (YYYYMMDDHHMISSXXX format). |
LastUpdateTimeMilliseconds | The time the procedure was last updated in milliseconds since Jan 1, 1900 00:00:00. |
LastUpdateUser | The ID of the user that last updated the procedure. |
Creating ProcedureInfo objects
Using New
One way of creating a ProcedureInfo object is with the New method. New takes two named input parameters that indicate the name of the procedure and of its procedure file or group:
%procInfo is object procedureInfo ... %procInfo = new(In='MYPROCFILE', Name='MYPROC') printText {%procInfo:name} {%procInfo:bytes} {%procInfo:lastUpdateTime}
New returns a Null object if the procedure is not found.
Using List
Probably the most common way of creating ProcedureInfo objects is using the List method. This is a shared method that returns an Arraylist of Object ProcedureInfo.
The List method has one required named parameter (In for the containing procedure file or group, and one optional named parameter (Name) to identify the procedures to be returned, with wildcards allowed. These wildcards are the User Language standard, non-regex, wildcards. Specifying no Name value is the same as specifying an asterisk (*) for the procedure name pattern: the information is returned for all the procedures.
For example:
%procInfoList is arraylist of object procedureInfo ... %procInfoList = %(procedureInfo):List(In='MYPROCFILE', Name='MY*') for %i from 1 to %procInfoList:count printText {%procInfoList(%i):name} {%procInfoList(%i):bytes} {%procInfoList(%i):lastUpdateTime} end for
Note: The List method does not have parameters to select procedures based on last update time or last updating user ID. You can accomplish the same thing by using the Arraylist subsetting methods though, this approach would be significantly more expensive if a large list were built only to select a small subset.
The ProcedureInfoList type
As a coding convenience, the ProcedureInfoList
type is defined as an "Arraylist of Object ProcedureInfo". Consequently, you can specify a declaration like the one in the preceding example for %procInfoList
more simply as:
%procInfoList is type procedureInfoList
Note: The keyword Type is required.
Example
The following example uses may of the ProcedureInfo methods:
OPENC SIRIUS b %procInfo is object procedureInfo %procList is type procedureInfoList %i is float %procList = %(procedureInfo):list(name='*SS*', in='GROUP SIRIUS') printText {~} = {%procList:count} %procList:sort(descending(lastUpdateTimeMilliseconds)) for %i from 1 to %procList:count %procInfo = %procList(%i) %procInfo = %procList(%i) printText {%procInfo:filename:left(8)} {%procInfo:firstPageNumber:left(10)} {%procInfo:name:left(34)} - {%procInfo:bytes:left(8)} {%procInfo:lastUpdateUser:left(10)} {%procInfo:lastUpdateTime} end for end
The result looks like this: %procList:count = 7 SIRIUS 04000773 SSLP-REQ 30846 ALAN 2011071509461684 SIRIUS 0400076E SSLP-PROCS 25888 ALAN 2011071509461681 SIRIUS 04000593 SSLP-SIGN 22908 ALAN 2008062010244706 SIRIUS 04000259 SSLP-RECV 25827 ALAN 2008062010244218 SIRIUS 040002AB SSLP-FILES 7201 ALAN 2008062010243551 SIRIUS 04000237 SSLN-START 10115 ALAN 2008062010243273 SIRIUS 04000566 SSLN-END 3632 ALAN 2008062010242969
ProcedureInfo advantages
The ProcedureInfo processing has several advantages over $list processing:
- It is more structured and robust than the comparable $list technology, and it uses the superior object-oriented syntax. Except in extreme cases, this alone is sufficient to justify using the ProcedureInfo class instead of the $list equivalents ($Proc_List, $Proc_ListG, $PrcLEx, and $PrcLExG).
- The ProcedureInfo New method does not scan the entire procedure dictionary, unlike the $list $functions. This can make the New method hundreds or even thousands of times more efficient than the comparable $list approach. And the List method is comparably efficient if the requested name contains no wildcards.
- If the List method specifies a wildcard that excludes a significant percentage
of the procedures in the context file, it becomes more efficient than the
$list equivalents. If fewer than 10% of the procedures are selected, a ProcedureInfoList
would be faster than the $list equivalent. If 5% are selected, then the ProcedureInfoList approach would be twice as fast. The reasons for the speed improvement are for internal technical reasons.
Note: Because the object-oriented infrastructure is a considerably "heavier weight" than a simple unstructured $list containing procedure information, using a ProcedureInfoList can be a factor of 3 to 5 times slower than equivalent $list (or Stringlist) processing. This includes procedure list extraction and possibly sorting. However, except for extremely large lists (>100,000 procedures), this is likely to be a minor cost (along the order of a few hundred milliseconds or less on a fast processor). And, for such large lists, it is quite likely that the I/O time for reading the procedure dictionary (which will be quite large and so likely to not all be in the buffer pool) will dominate.
List of ProcedureInfo methods
The "List of ProcedureInfo methods" contains a complete list of the class methods.