ThreadHistory

(Engine-Level Function)

Description: Returns in an array, the history of execution for all threads.
Returns: Multidimensional Array
Usage: Script Only.
Function Groups: Basic Module
Related to: Thread | ThreadList | ThreadName |
Format: ThreadHistory(Unused, ArrayToPopulate, NumRecords)
Parameters:  
Unused
Reserved. Should be set to Invalid.
ArrayToPopulate
Name of the array. See comments.
NumRecords
Defaults to 10,000 if not specified.
Comments:

The return value for ThreadHistory is a listing of the last 8192 operations on the thread (max) with five data points per operation. This array should be interpreted in the format, [column][row].

The five rows (data points per operation) are as follows:

0 = Time of execution
1 = Module, State and Statement (type 13) for the operation
2 = State name where the operation is located
3 = Statement number of the operation
4 = Object value for the owning module instance

The second parameter is typically populated by using the result of calling ThreadHistory once with an empty array. For example, if you want to obtain the execution history every 5 seconds, you might use the following code to save having to build a 10000-element array every time:

If TimeOut(1, 5);
[
  ExecuctionHistory = ThreadHistory(Invalid, ExecutionHistory, 10000);
]

The first time the above is called, ExecutionHistory will be Invalid so ThreadHistory will build, populate, and return a multi-dimensional array with 10000 elements.

The second time it is called, ExecutionHistory will have been set to the array of the right size / dimensions. ThreadHistory will populate the array it was given and return it, rather than creating a new array.