Trace (Arraylist subroutine)

From m204wiki
Revision as of 21:29, 2 February 2011 by JAL (talk | contribs) (→‎Examples)
Jump to navigation Jump to search

Trace Arraylist (Arraylist class)


The Trace subroutine displays the contents of an Arraylist in a readable form on the currently selected trace stream. The listed item values are displayed in ascending order by their position and, by default, are preceded by their item number, a colon and a blank space (': ').

Trace is identical to Audit and Print, except their output is sent to the Model 204 audit trail (like the User Language Audit statement) and user's standard output (terminal) destinations respectively.

Syntax

al:Trace[( [itemFunction], [NumWidth= number], [Separator= string], - [Start= number], [MaxItems= number], [Label= string])]

Syntax terms

al An Arraylist object.
method The method that is to be applied to al items to produce the trace output. The method must take no parameters and produce an intrinsic (be that Float, String, Fixed or Unicode) value. It may be a system or user-written method, a class variable or property, a local method, or a method variable.

The default value of method is ToString.

NumWidth The number of bytes in the display of each item to use for the item number. This is an optional, but NameRequired, parameter; if you specify a value, the parameter name NumWidth is required.

Item numbers are right-justified within the indicated number of bytes, and they are truncated on the left if the length of the item number exceeds the space allocated for it. The NumWidth must be a number between -1 and 10 inclusive. If you specify a value of 0, the item number is not displayed.

If NumWidth is -1, the default, the method uses the minimum number of bytes required to show the item number. For example, one byte is required for item number 5, while five bytes are required for item number 98764.

Separator A string, 15 characters or less, to be used to separate the item number from the item value. This is an optional, but NameRequired argument; if you specify a value, the parameter name Separator is required.

The default value for Separator is a colon (':'); and a blank always follows the Separator string.

Start The item number of the initial item in the output display. This is an optional, but NameRequired, argument; if you specify a value, the parameter name Start is required.

The default value for Start is 1; to start with the first item in the al.

MaxItems The maximum number of items to display. A zero or negative value means to display all the items. This is an optional, but NameRequired, argument; if you specify a value, the parameter name MaxItems is required.

The default value for MaxItems is 0; to display all items from Start to the end of the al.

Label A literal string that gets output before each line. This is useful for "tagging" lines to make them more identifiable. This is an optional, but NameRequired, argument; if you specify a value, the parameter name Label is required.

The default value for Label is the null string ''; to not display any additional "tag" information.

Usage notes

  • All errors in Trace result in request cancellation.
  • Audit and Print are the same as Trace except they send their output to the Model 204 audit trail or currently selected trace destinations, respectively.

Examples

For examples of Trace method calls, see Printing a collection.

See also