You can set preferences for the display of source code in the editor window.
This section contains information on:
You can format source code by indenting source-code lines. Indentation is performed differently for sources created in reporting mode than for sources created in structured mode. In addition, you can color syntax elements for better readability. Syntax coloring is set on by default. However, you can change the default color definitions or switch syntax coloring off.
To format source code
Place the cursor anywhere in the source code.
From the
menu choose .Or:
Choose the following toolbar button:
Or:
In the command line, enter the following system command:
STRUCT
See also STRUCT
in the
System Commands documentation.
The lines in the source code are indented.
To change syntax coloring
Change the default color settings by using the Colors editor option, or switch Syntax coloring off as described in Program Editor Options in the Using Natural Studio documentation.
You can show (expand) or hide (collapse) logical blocks of source code to improve readability and maintainability of objects with complex code structures. When a block of source code is collapsed, all of the lines of source code between the block begin statement and block end statement are hidden, including any other nested blocks if they are part of the chosen block. Hidden blocks retain their collapsed or expanded status.
Expanding and collapsing code blocks only applies to object sources that were created in structured mode.
Code blocks that can be expanded or collapsed are, for example,
DEFINE DATA
blocks,
REPEAT
blocks, IF THEN ELSE
blocks,
READ
blocks, and blocks of two or more consecutive
comment lines.
When scanning source code, collapsed blocks can be excluded from the search. For more information, see Finding Text.
When you are searching for a line number in source code that is part of a collapsed block, the block is expanded to display the line. For more information, see Going to a Line Number.
If you want to expand and collapse code blocks, you need to set the appropriate editor option referenced in the instructions below.
To expand and collapse single code blocks
Set the Expand/Collapse editor option as described in Program Editor Options in the Using Natural Studio documentation.
When the Expand/Collapse option is set, an expand or a collapse toggle ( or ) appears as shown in the example below:
The toggle indicates the first line of an expanded block.
Each block is marked with a vertical line that goes from the begin
statement (here, for example: DEFINE DATA
) to the end statement
(here: END-DEFINE
).
The gray vertical bar in the column next to the source-line numbers
indicates the current block (here: REPEAT
) which depends on the
logical relationship of the statement where the cursor is positioned. In the
example above, the cursor is positioned in the INPUT
statement
line which belongs to the REPEAT
loop. (IF
and the
READ
are separate nested loops.)
The toggle indicates the first line of a collapsed block.
Click on the toggle to expand the block or click on the toggle to collapse the block.
Or:
To expand a block and insert a line:
Place the cursor in the first position of a toggle line and press SHIFT+ENTER to expand the block and insert a line above the expanded block.
Place the cursor in the last position of a toggle line and press SHIFT+ENTER to expand the block and insert a line below the expanded block.
If you place the cursor in the first or last position of a toggle line and choose ENTER, a line will be inserted above or below the collapsed block but the block will not expand.
Or:
Position the cursor within a line that contains the toggle
or
and, from the menu, choose
or choose the following toolbar
button:
To expand or collapse all code blocks
From the
menu, choose or .Or:
Choose either of the following toolbar buttons:
(
) or ( ).You can split the program editor window vertically or horizontally to view and modify two different parts of the object simultaneously. This feature saves you the trouble of printing an object source to view two different sections simultaneously. Changes made in one section are made simultaneously in the other section.
You can jump between split windows.
To split the editor window into two sections
From the
menu, choose or .Or:
Choose either of the following toolbar buttons:
(
) or ( )The mouse pointer changes to a split pointer.
Drag the line to the left/right or up/down to the position you want by either moving the mouse or using the arrow keys.
Freeze panes by either clicking the left mouse button or pressing the ENTER key.
The screen is split into two sections, each displaying the same information. You can now scroll each section individually and edit both sections as if they were part of the same object (as indeed they are).
To exit split-editor mode and return to a single screen
From the
menu, choose .Or:
Choose the following toolbar button:
Two editor sections are transformed into one.
To jump between split screens
Place the mouse pointer in the required screen section and click.
Or:
Press F6.
The cursor moves from one screen section to the other.