Implement Tracing

Stack tracing is only as good as the discipline used by the programmers of the dashboard. Stack trace relies on each function calling Qiq_trace at the beginning and just before the end. The sample code illustrates how code should be written:

function myFunction(){
  Qiq_enter(“myFunction”,1,this.Parent)
  for (var a=1;a<=this.Parent.Shapes.Count;a++){
    Qiq_trace(“looking at shape “+a,2,this.Parent)
    // 
  }
  //
  Qiq_exit(“myFunction”,1,this.Parent)
}

Qiq_trace takes these three parameters:

A String

Added to the stack. If the string starts with In followed by a space, it is assumed to be the start of the function. If the string starts with Out followed by a space, it is assumed to be the end of the function. If it does not start with In or Out it is assumed to be an inline call, and is not recorded in the stack trace. Inline calls are written to the trace report if tracing is turned on for the component and the second parameter is beneath the trace level requested.

A Number

Indicates the trace level for the call to be displayed in the full trace report or log. A stack trace is maintained no matter what trace level is selected. For example, the entry and exit from the function is reported if the trace level is 1 or greater. The iterations of the for loop are reported only if the trace level is 2 or greater. See Full Tracing.

A Section Identifier in which the Code is Located

JavaScript code is held inside controls such as buttons, check boxes, and so on. this refers to the control in whose event handlers the code is entered and .Parent refers to the parent object in which the object exists. The shorthand is recommended over the full and explicit naming of the section, because it enables you to rename the section or object, or move JavaScript to another section without having to change the code to reflect the changes made.

Note:

A trace statement must be added to all points in a function where the code execution may exit. The JavaScript return statement causes an early exit. All statements following return are not executed. Thus, the call to the Qiq_trace should be placed on the line immediately before a return statement.