HyperMath

Working with Scripts

Working with Scripts

Previous topic Next topic Expand/collapse all hidden text  

Working with Scripts

Previous topic Next topic JavaScript is required for expanding text JavaScript is required for the print function  
hmtoggle_plus1greyCreating Files

The simplest way to create a HyperMath (.hml) file is by clicking the New File icon from the File Toolbar. From the menu bar, you can select File > New to display the File Types dialog.

file_new_dialog

Select HMath File as the type. In both cases, an HML file named Untitled (followed by a number) is created and opened for editing.  Other file types can also be created by the second approach.

A new file of any supported type can be created directly from the Project Browser by right-clicking on the Files folder and selecting Add New File from the context menu.  The file name is added to the Files folder in the Project Browser.

addnewitemmenu    

Add New File context sensitive menu option

A script file can be opened using the File > Open menu by selecting the file type Script from the list box.

An existing file can also be opened by selecting the Files folder in the Project Browser and selecting Add Existing File from the right-click menu options.  The file name is added to the Files folder in the Project Browser.

Existing files can always be opened by double-clicking on the file from the File Browser.

Closing a file simply removes it from the editor but keeps in the Project Browser (if present) for future retrieval.  An open file in the editor can be closed by selecting File > Close, by right-clicking on its icon in the Project Browser and selecting Close or by clicking the cross marker in its tab.

hmtoggle_plus1greyRunning

You can run the current file in the editor by clicking the Run File toolbar button, run_file_icon, or by right-clicking the editor and choosing the same option.  Once a script is executed, all functions defined in the script are also available from the command window – that is, they can be called from there, too.

Debugging

To debug a script in the editor:

1.From the Debug menu, select Start Debugging or press F5.

Once in Debug mode, the other windows are activated.

2.Set the breakpoints by clicking the left margin next to the desired line.
3.Start the debugging process by clicking Run File on the toolbar or right-clicking the editor and choosing the same option, run_file_debug_icon.
4.Once a breakpoint is hit, a yellow arrow is displayed inside of it.  This indicates the next line of execution.

breakpointyellow

5.Click Step Over, step_over_icon, on the toolbar to execute the current line and move over to execute the next one.  The yellow arrow on the margin moves to that point.
6.Click Continue, continue_debug_toolbar, to resume execution until the next breakpoint is hit in the remaining execution path or the end of script is reached.
7.Clicking Step Into, step_into_icon, to enter any user written function call at the current line of execution.  If none exists, it behaves like Step Over.
8.Conversely, click Step Out, step_out_icon, to cause it to come out of the current function and to the point where the function was called.

If the current line of execution is not inside any function, this behaves like Step Over.

9.Click Step Until, step_until_icon, to continue the execution and stop at the line of the cursor if it is in the remaining path of execution.  Otherwise, it behaves like Continue.  It honors breakpoints residing in the execution path.

For a complete debugging example, please refer to the tutorial HMath-1020: Working with the HyperMath Debugging Mode.