Opening the Editor
Double-click an OptoScript block to open the editor. You can resize the editor window as needed.
Editor Menu Buttons
Below, is an explanation of the Editor menu buttons and the green comments shown in this example.
When you type code in the top area, the text is color-coded:
– Blue: Operators and control structures
– Purple: Values
– Green: Comments
– Black: Commands and names of variables, I/O points, charts, and other items
– Red: String literals
To Insert a Command
1. Put your cursor in the code area where you want to insert a command.
2. Click on the Insert Actions button in the toolbar to see a list of command groups and their commands.
3. Select the command group in the left-hand column, and the OptoScript command on the right-hand column.
For information on any command, highlight it and select Command Help to learn more.
4. Click OK, and the command appears in the OptoScript code.
To Insert a Variable, Table, I/O Point, or Similar
1. Put your cursor in the code area where you want to insert a variable, table, I/O point, or similar item.
2. You can type it in exactly as you've created it, but it's recommended you use the Insert Variable button in the toolbar.
3. A list of all of the variable types and their names are listed.
Select the variable type on the left, and the variable name on the right, click OK, and the variable appears in your code.
Enter comments to document what the code does so that anyone who has to debug or maintain the code, can understand.
Comments appear in green. Line comments must be preceded by two slashes.
// This is a line comment.
Block comments must be preceded by a /* and be followed by a */.
/* This is a block comment that goes
beyond one line. */
When you've entered the code for an OptoScript block, click the Test Compile button in the toolbar to compile the code. The code is compiled, and the results appear in the bottom part of the OptoScript window:
If there are any errors, fix them by starting with the first one listed. This is because later errors are often a result of earlier errors.
When you've finished with the code in the OptoScript block, click OK to save your work, close the editor, and return to the flowchart.