The Code Editor is used to edit source code for the Calculator, a Script, or a Template. Three tabs are available along the top of the window, one for each type of file that can be edited:
- Calculator - The calculator is a scratch pad for doing mathematical calculations. The syntax for the calculator is identical to Scripts and is explained briefly in the Calculator help topic.
- Script - Displays the currently loaded Script. Scripts have the extension ".1sc" and are similar in syntax to C. Use scripts to edit files, interact with templates, or work with the interface. See Script Basics for an introduction to writing Scripts.
- Template - Shows the currently loaded Binary Template. Templates have the extension ".bt" and have a syntax similar to scripts but with some important differences. Template Basics for an introduction to writing Templates.
The three panels that are displayed in these tabs have a number of controls in common:
The main area contains a text editor for the file. The syntax of this editor is highlighted and line numbers are displayed along the left-hand side. Below the text editor is the Output text area that will display any errors, warnings, or messages while running a Script or Template. Any text printed out with the Printf function will also be displayed in the Output text area (see Interface Functions). Pressing F1 while the cursor is over a keyword or function name will bring up help on that item.
Along the top of the window are four icons. The image will change depending upon which tab is selected, but the functionality remains basically the same:
- New - Clears the current file and creates a new Script or Template.
- Open - Opens an existing Template or Script.
- Save - Saves the currently loaded Script or Template.
- Save As - Saves the loaded Script or Template to a new file name.
For Scripts and Templates, the current file name will be displayed in the Code Editor title bar. Note that only one Script or Template can be loaded at a time. If the file is modified, a '*' will appear beside the file name in the title bar. Whenever a new Script or Template is loaded, you may be asked to save any changes if the current file has been modified. Templates can be configured to automatically load and run when a file is opened (see Template Options for more information).
On the right side of the Code Editor the Variables list is displayed. Any variables defined in a Script will be displayed here after the Script is run. If an array is defined in the Script, clicking the '+' beside the variable name will display all members of the array. Note that the Variables list is not displayed for a Template since variables defined in a Template are displayed in the Template Results panel below each Hex Editor Window (see Working with Template Results).
Also displayed on the right side of the window is the Functions list. All functions are sorted into five categories: Interface Functions, I/O Functions, String Functions, Math Functions, and Tool Functions. Click the '+' beside each function group to list all functions in that group. The All group lists every function in alphabetical order. Double-clicking on a function name will insert that function into the text editor at the cursor position.
Click the Run button at the bottom of the dialog to execute the Calculator, Script, or Template. If execution is taking a long time, the Esc key can be used to cancel the operation. Note that results from the Calculator or Script are displayed in the Output text area, and the results from the Template are displayed in the Template Results panel below each Hex Editor Window. Clicking the Close button or pressing the Esc key will dismiss the Code Editor window. Warnings are also displayed in the Output text area by default, but can be disabled by using the Code Editor Options dialog.
NOTE: The Code Editor is a dockable window. By clicking and dragging on the title bar of the Code Editor, the window can be moved to other locations in the interface. Right-click the window and deselect the Allow Docking toggle to prevent the window from docking. By default, the Code Editor is always displayed on top of the 010 Editor main window. To allow the Code Editor to be moved behind the main window, right-click the Code Editor and deselect the Always on Top toggle.
|