Manual Script Creation in Eggplant Functional
You can always create scripts manually from scratch by creating a new Eggplant Functional script in the Script Editor and writing your own SenseTalk code. In addition, after you generate code through one of the methods described above, most scripts will require some further organization and editing, which you can also accomplish in the Script Editor. For more complex workflows, manual SenseTalk scripting is required.
There are several ways to insert commands and images into a script:
- Type commands, functions, and image names in the Script Editor.
- Choose commands from the Control menu.
- Choose commands from the Insert drop-down list on the Script Editor toolbar.
- Use the SenseTalk Browser in the right sidebar of the Script Editor to find and insert commands, functions, and code snippets.
- Copy, cut, and paste with the Edit menu or associated keyboard shortcuts.
- Drag image, script, suite, and SUT names into the Script Editor from other windows.
Auto-Completion
The Script Editor includes code completion. When you type at least one character in the Script Editor, Eggplant Functional will bring up a list of suggested completions, including variables, commands and functions, names of scripts or images from your current suite, handlers, and helpers. For more information, see Auto-Completing Handlers and Helpers.
To disable or change auto-completion preferences, go to eggPlant > Preferences, navigate to the Script tab, and select the Completion pane.
When typing, suggested word- or code-completions appear in a pop-up box. Selecting one of the options listed displays a formatted example for that suggestion at the bottom of the pop-up:
To select an item from the list of options, you can use your arrow keys, your mouse, or continue typing until the item you want is shown at the top of the suggestion list. To insert the selected item, press Tab or Enter.
You can insert blocks of code, such as if... then... else
conditional statements, or repeat
loops. In such cases, the inserted code typically has tokens that you will need to replace with the specific values appropriate to your script:
If you don't want to use any of the suggested completion options, you can continue typing, or press Escape to dismiss the pop-up box. Remember, you can adjust auto-complete functionality in the Script Preferences to control what items are suggested, as well as other details about how auto-completion works.
Auto-Completing Handlers and Helpers
To auto-complete a new handler (using to
/to handle
, on
, or function
), make sure that Handlers is enabled in the Script preferences Completion pane under Auto-Complete Statements.
To trigger the completion suggestion for a handler located in a helper script within the same suite as the script you are writing, simply start typing the name of the handler:
Auto-completion will also provide completion suggestions for scripts and their handlers located in helper suites. To trigger this, start typing the name of the script in your helper suite that you want to access. The script will show as normal, but the name of the suite it is in will show in parentheses to the right of the "Script" identifier, as shown below:
After the script is auto-completed, use dot notation to begin adding a handler from within that script:
Auto Indenting
Auto indenting puts tab or space characters inside control structures to make scripts easier to read. (Control structures include handlers, repeat loops, if/then/else and try/catch commands.)
By default, the Script Editor updates indentation when you press Return or Tab. (You can change this behavior in Script Editor preferences.)
Colorization
By default, each type of script element (such as command, variable, and image name) is written with a different color in the Script Editor. This can make it easier to track what is happening in the script.
If you use incorrect syntax (that is, code that doesn’t make sense to Eggplant Functional) the entire line or block that contains the error is not colored; this is a visual cue that there is a problem in the script.
Colorization can be customized extensively in the Script Editor preferences.
Menu Features
The Edit and Format menus contain many of the features you find in word processors. Use these menus for standard editing tasks such as finding text, cutting and pasting, and changing font styles.