HyperMath

HMath-5004: HyperMesh-HyperMath Cross-debugging of a Tcl Script

HMath-5004: HyperMesh-HyperMath Cross-debugging of a Tcl Script

Previous topic This is the last topic No expanding text in this topic  

HMath-5004: HyperMesh-HyperMath Cross-debugging of a Tcl Script

Previous topic This is the last topic JavaScript is required for expanding text JavaScript is required for the print function  

Tcl macros written for HyperWorks can be debugged using HyperMath. This eliminates having to use print statements to guess the location of where the macro failed to work.

The only requirement to debug a Tcl script in HyperMath is that the Tcl macro must be contained in a procedure.

This tutorial demonstrates how to link HyperWorks Desktop with HyperMath for live debugging. The Tcl script used in this tutorial allows you to select a single circle and outputs the radius and the diameter of the circle. As the Tcl script is debugged, it demonstrates how to use the Watch and Breakpoints windows, for example.

Step 1: HyperMesh Desktop – Load the model

1.From the Start menu, select All Programs > Altair HyperWorks 2017.0 > HyperMesh Desktop.
2.From the menu bar, click File > Open > Model.
3.From the Open Model dialogue, open the radius.hm model file, located in the hmath folder. The model is displayed in the graphic area:
 
hmath_5004_img1

Step 2: Invoke HyperMath in HyperWorks Desktop

1.From HyperMesh Desktop menu bar, click View > Toolbars > HyperWorks > Scripting to display the scripting toolbar.

hmath_5004_img2

2.From the Scripting toolbar, click the third icon, hmath_5004_debug_icon (Debug Tcl/Tk script), to load and debug a Tcl script.

Select the file radius.tcl from the hmath folder (for more information, see tutorial Hmath-5003).

This invokes HyperMath’s Tcl Editor in debug mode (note the Debug toolbar is displayed).

hmath_5004_img3

3.Set some breakpoints in the Tcl script, for example, at lines 21 and 26.

hmath_5004_img4

4.From the Debug toolbar, click Continue.

The Tcl script is executed until line 20. Note that at line 8, the control is transferred back to HyperMesh Desktop and in HyperMesh Desktop, you must select a line in the model (pick any hole).

Now the execution is stopped just before line 21 as indicated by the cyan arrow.

hmath_5004_img5

5.Click Continue, continue_debug_toolbar, until the debugger reaches the next breakpoint (line 26).

Note that at any time, by placing the mouse pointer over a value in the Tcl script, variable values can be inspected.

hmath_5004_img6

6.Using the Watch and Call Stack windows (as described in tutorial Hmath-1020) add breakpoints to perform further inspections in the script.

Eventually, the message box created at line 33 is displayed.

hmath_5004_img7

7.Upon reaching the final statements of the script, the debugging is complete and the process is stopped.

hmath_5004_img8

See Also

HMath-1000: Editing, Executing, Saving, and Plotting in HyperMath

HMath-1010: Working with HyperMath Authoring Mode

HMath-1020: Working with HyperMath Debugging Mode

HMath-2000: Working with HyperMath – Arithmetic and Relational Expressions and Control Structures

HMath-2010: Working with HyperMath – Logical and Relational Expressions and Control Structures

HMath-2020: Working with HyperMath – Functions and Matrix Operators

HMath-2030: Working with HyperMath – Plot Commands

HMath-3000: Working with HyperMath – String Library

HMath-3010: Working with HyperMath – Input/Output Library

HMath-3015: Reading Data from Text Files

HMath-3020: Working with HyperMath – Input/Output Library Continued

HMath-3030: Working with HyperMath – Batch Mode

HMath-4000: Using HyperMath Functions for Curve Fitting

HMath-4001: Using HyperMath for Material Characterization

HMath-4010: Solving Ordinary Differential Equations

HMath-4020: Solving Differential Algebraic Equations

HMath-4030: Optimization Algorithms in HyperMath

HMath-5000: Using HyperMath in HyperView Results Math

HMath-5001: Post Processing Results from FEA

HMath-5002: Registering a Function in HyperGraph 2D

HMath-5003: HyperMesh-HyperMath Cross Execution of a Tcl Script