ProcedureInfo class

From m204wiki
Jump to: navigation, search

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.

A ProcedureInfo object provides information such as the size of a procedure and the date and user ID of its last update. 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.

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 SOUL standard, non-regex, wildcards.

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

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.


The following example uses many of the ProcedureInfo methods:

OPENC SIRIUS b %procInfo is object procedureInfo %procList is type procedureInfoList %i is float %procList = %(procedureInfo):list(name='SSL*', in='GROUP SIRIUS') printText {~} = {%procList:count} %procList:sort(descending(lastUpdateTimeMilliseconds)) for %i from 1 to %procList:count  %procInfo = %procList(%i) printText {%procInfo:filename:left(8)} {%procInfo:name:left(16)} {%procInfo:bytes:left(8)} - {%procInfo:lastUpdateUser:left(10)} {%procInfo:lastUpdateTime} end for end

This is a sample result:

%procList:count = 7 SIRIUS SSLP-REQ 30846 ALAN 2011071509461684 SIRIUS SSLP-PROCS 25888 ALAN 2011071509461681 SIRIUS SSLP-SIGN 22908 ALAN 2008062010244706 SIRIUS SSLP-RECV 25827 ALAN 2008062010244218 SIRIUS SSLP-FILES 7201 ALAN 2008062010243551 SIRIUS SSLN-START 10115 ALAN 2008062010243273 SIRIUS 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 (more than 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.