6.4.2   Editing Programs

The program window supports full text editing, i.e., text can be freely edited by placing the text cursor with the left mouse button and typing away. Continuous portions of text may be selected by dragging with the mouse. An existing selection may be extended by holding down Shift and clicking the left mouse button. Double-clicking selects the word under the mouse pointer while triple-clicking selects the entire line.

To edit a program line in the operator window, double-click it with the left mouse button. If the operator window is not currently open, hold down Ctrl while double-clicking.

Comments

Comments start with an asterisk (*) as the first (non-whitespace) character. You may also add comments at the end of regular program lines by introducing them with //.

  * this comment is ignored during program execution
  read_image (Image, 'clip')             // instantiate iconic variable
  threshold (Image, Region, 0, 63)       // select dark pixels

Special input formats

Certain operator calls may be entered in different formats. Syntactically, they are equivalent but the first variant is more readable and thus recommended. It is also the one used when entering the corresponding calls via the operator window.

Note that for loops always have to be entered in the following format:

for Index := Start to End by Step
 ...
endfor

Line continuation

Operator calls may span several lines for readability. A line may be continued by entering a backslash character as the last character of that line.

For example, you can enter

disp_arrow (WindowID, \
            Row[i], \
            Column[i], \
            Row[i]-Length*sin(Phi[i]), \
            Column[i]+Length*cos(Phi[i]), \
            4)

instead of

disp_arrow (WindowID, Row[i], Column[i], Row[i]-Length*sin(Phi[i]), Column[i]+...

Auto Indenting

The indent of new lines is adjusted automatically. Usually, the indent of the previous line is maintained. If a line is continued inside the parentheses of an operator call, the new line is indented up to the opening parenthesis. If the previous line opens a control structure (e.g., if or while), the indent is increased by the indent size. The indent size is specified in the preferences (see Program Window). It defaults to four spaces. If a control structure is closed (e.g., by entering endif or endwhile), the indent of the current line is decreased by the indent size.

Advanced Autocompletion

The program window provides advanced autocompletion to support you in several ways.

Special Keyboard Shortcuts in the Program Window

General:

Tab cursor at the beginning of line: adjust indentation of current line
selected text: indent corresponding code lines one level
Shift+Tab selected text: outdent corresponding code lines one level
Shift+Return reverse action of Return key (see Program Window Actions)
Ctrl+Return execute current line (same as clicking Apply in operator window, see section “Control Buttons” on page 362)
Ctrl+F open find/replace dialog with selected text (section “Find/Replace...” on page 143).

Advanced autocompletion:

Escape hide suggestion list
Ctrl+Space re-display suggestion list based on cursor position or selection
Up highlight previous entry in suggestion list
Down highlight next entry in suggestion list
Tab operator suggestions: complete to highlighted suggestion or to longest common string from suggestion list
parameter suggestions: complete to highlighted suggestion or first suggestion if no suggestion is highlighted
Return cursor at the end of a block statement: insert the corresponding end statement of the block

Special Operator Handling

Some operators provide additional functionality when being edited. This functionality is available via an action button next to the parameter field in the operator window, or as an action button in the advanced autocompletion suggestion list.

If an operator contains a parameter that specifies a file name, the parameter value can be specified in a file selection dialog. See the previous section for an example (read_image).

The operators info_framegrabber and open_framegrabber provides a button to detect the available image acquisition interfaces automatically (see also Image Acquisition Assistant).