Topic: P343

Structured Text Editor

Mnemonic (Keyboard Shortcut) = STE

Icon / Button =


Structured Text Editor Overview

Structured Text Editor is an extremely powerful feature of the Productivity Suite software that improves the maintainability, uniformity, and readability of your routines.


Structured Text Editor Window

The Structured Text Editor Window, also known as the ST Task Window or ST Task Pane, is the area where all Structured Text (ST) program code is written, edited, compiled, debugged, and monitored. The Structured Text Editor shares the same workspace location as the Ladder Editor but with features specific to Structured Text programming.

The Structured Text Editor Window is divided into two main areas:

  1. The “Header” provides the user with some viewing, navigation, and coding options.
  2. The “Editor” area is where the ST code is written, edited, and monitored.

The Header

The Header displays the name of the Structured Text task currently open and includes commonly used controls for programming and viewing the task.

The drop-down arrow to the right of the header icons provides the Show Icon Descriptions option. When selected, the Show Icon Descriptions option will populate the header with icon descriptions as seen below.

 


The following section describes each of the header options:

 

  1. Undo / Redo controls – revert from or reapply the most recent code change.
  2. Find / Replace controls – open Find /Replace dialogs to search for text within the current task.
  3. Zoom Controls – Increase or decrease text zoom level. Maximum zoom is 300%. Minimum zoom is 25%.
  4. Line Wrap – toggles line wrap of text and code in the current task.
  5. Expand / Collapse All Folds – toggles the expansion or collapsing of all code or text that can be expanded or collapsed, such as IF, FOR, WHILE, REPEAT, or CASE code blocks, multiline comments, etc.
  6. Indent controls – increases or decreases the indentation of the selected lines of code.
  7. Task Comment – toggles the display of the task comment in the header”

  8. Comment controls – toggle commenting or uncommenting selected lines of code to/from single line or block comment.
  9. Insert Code Block – insert a template of an IF, FOR, WHILE, REPEAT, or CASE code block.

 

  1. Insert Function – view and insert a function from the list of available functions

  1. Function Type lists the eight categories of functions and function blocks.
  2. List of function or function block names in the currently selected category.
  3. Description of the function block – includes parameter names and what the function does.

Note: A complete list of all available functions can be found in the Structured Text Function List help topic. Parameters in the description that are orange are optional and not required for the function to compile.

  1. Validate – compile/verify the code in the current task. If there are no syntax errors, a Define Tags dialog will appear allowing the creation of any undefined tags in the code.
  2. Navigation Controls – navigate between errors in the code or to a specific line of code.
  3. Go To Line – opens a dialog that allows the user to place the cursor on a specific line of code
  4. Monitor – toggles online monitoring mode which will display tag values inline in the code

 

The Editor

The Editor is a text editing interface where Structured Text code is entered and displayed.

 

 

  1. Line numbers are displayed along the left side of the editor.
  2. Code blocks (such as IF, FOR, WHILE, REPEAT, or CASE) and multi-line comments can be expanded or collapsed by clicking the ‘-‘ or ‘+’ next to the first line of the code block or multi-line comment.
  3. The cursor location is displayed at the bottom of the editor window – for example L21:C100 means the cursor is at line 21, column 100”

Code Entry and Formatting

The ST Editor has the following features to aid in writing and formatting code:

  1. Automatic indentation after IF, ELSE, CASE, FOR, WHILE, and REPEAT statements.
  2. Automatic completion of IF, ELSE, CASE, FOR, WHILE, and REPEAT statements. To do this, type the first line of the statement, then type Shift + Enter.
  3. Context menu formatting options.
  4. Inline filtering (Auto-Complete) – type Ctrl + Space to display a selectable filtered list of available tags and functions based on the contiguous text immediately preceding the cursor (e.g. type “ac” then Ctrl + Space to display a list of all functions and tags that start with “ac”). Use the mouse or arrow keys to select the desired function or tag to insert. Double-clicking the mouse or typing Enter or Tab will insert the selected function or tag into the code.
  5. Inline function list – type Ctrl + Shift + Space to display a selectable list of available functions. Use the mouse or arrow keys to select the desired function to insert. Double-clicking the mouse or typing Enter or Tab will insert the selected function into the code will all parameters (required and optional).

 

 

Note: The ST Editor supports up to 4096 lines per task.

 

The following is a list of keyboard shortcuts supported by the ST editor:

Code Status Indicators

The ST Editor visually indicates undefined tags, incorrect parameters, and syntax errors using red underlines. See below for some examples:

 

 

 

In addition, the following icons indicate the status of each line of code that is written:

Comments

To add a multi-line comment, enclose the comment with (* and *). Everything within will be considered a comment and will not be validated or compiled as code. Multi-line comments have no restriction on the number of lines.

To add a single-line comment, use //. Everything after // will be considered a comment and will not be validated or compiled as code.

 

Related Topics: