6.17.2   Editing Programs

The program window supports full text editing. Continuous portions of text can be selected by dragging with the mouse. An existing selection can 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 character. You can 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 can 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 can span several lines for readability. A line can 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 (for example, 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 (for example, 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

Tab Cursor at the beginning of line: Adjust indentation of current line
Selected text: Indent corresponding code lines one level
AC Operator suggestions: Complete to highlighted suggestion or to longest common string from suggestion list
Shift+Tab Selected text: Outdent corresponding code lines one level
Ctrl+Return Execute current line (same as clicking Apply in operator window; see section “Control Buttons”)
Shift+Return Cursor at the end of line: Execute current line and insert new line (depends on the setting of the Select the behavior of pressing the [Return] key option; see section “General Options General Options)
Ctrl+F Open find/replace dialog with selected text (see section “Find/Replace Dialog”).
Escape AC Hide suggestion list
Ctrl+Space AC Re-display suggestion list based on cursor position or selection
Up AC Highlight previous entry in suggestion list
Down AC Highlight next entry in suggestion list
AC Parameter suggestions: Complete to highlighted suggestion or first suggestion if no suggestion is highlighted
Return AC Cursor at the end of a block statement: Insert the corresponding end statement of the block
Entries marked with AC are only available if advanced autocompletion is enabled.

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 provide a button to detect the available image acquisition interfaces automatically (see also 图像采集助手).