Example

The following example shows how to send trace messages to the Java console. This example uses the following action elements: Trace and Variable update.

You can copy the text of this macro script from this document into the system clipboard, and then from the system clipboard into the Code Editor (see Copy and paste a script from this guide into the Code Editor). After you save this script in the Macro Editor, you can edit it either with the Macro Editor or with the Code Editor.

You should notice the following facts about this example:
  • The example consists of one entire macro script named TRACE.
  • The <create> element creates a string variable named $strData$ and initializes it to an original value of 'Original value'.
  • The first action is a Trace action with the Trace Text set to 'The value is' + $strData$.
  • The second action is a Variable update action that sets the variable $strData$ to a new value of 'Updated value'.
  • The third action is another Trace action identical with the first Trace action.
Figure 1. Sample code TRACE
<HAScript name="TRACE" description=" " timeout="60000" pausetime="300"
            promptall="true" author="" creationdate="" supressclearevents="false"
             usevars="true" ignorepauseforenhancedtn="false"
             delayifnotenhancedtn="0">
   <vars>
      <create name="$strData$" type="string" value="'Original value'" />
   </vars>
   <screen name="Screen1" entryscreen="true" exitscreen="false" transient="false">
      <description>
          <oia status="NOTINHIBITED" optional="false" invertmatch="false" />
      </description>
      <actions>
         <trace type="SYSOUT" value="'The value is '+$strData$"  />
         <varupdate name="$strData$" value="'Updated value'" />
         <trace type="SYSOUT" value="'The value is '+$strData$"  />
      </actions>
      <nextscreens timeout="0" >
      </nextscreens>
  </screen>
This script causes the macro runtime to send the following data to the Java console:
The value is +{$strData$ = Original value}
The value is +{$strData$ = Updated value}
In the trace output above you should notice that instead of just displaying the value of $strData$, the Debug action displays both the variable's name and its value inside curly braces {}.