The editing area is either empty or contains source code that was last
read into the source work area with the command EDIT
or READ
as shown in the example of a program in
Invoking the Program
Editor.
When you read in the source of an existing object, the entire source code is loaded into the source work area and is available for editing. However, depending on the size of the source, the editing area may not show all of the lines that belong to the source. In this case, you have to scroll down the source (see Editor Commands for Scrolling) to go to the line you want to view or modify.
In addition, if you use split-screen mode (see the relevant section), the editing area displays fewer lines of source code.
You can use multiple methods to create or modify source code:
Type in or update text directly in the relevant source line.
Use one or more line commands as described in the relevant section.
A line command, for example, is used to insert or delete a line or copy variable or field definitions within the current source.
Use one or more editor commands or alternative PF keys as described in Editor Commands for Scrolling, Editor Commands and Displaying and Modifying PA/PF-Key Assignments.
An editor command, for example, is used to scroll in the source, find and replace text strings, undo an edit action, invoke the editor profile facility or display another object from which you can copy variable or field definitions.
This section covers the following topics:
This section provides example instructions for using a line command to insert text into the current source.
To insert text into a source
In the leftmost column of the prefix area, next to the required
source line, enter an I
(insert) command (see
Line Commands) thus temporarily overwriting the characters
in the prefix area.
For example, enter the following line command:
I5
Insert mode is activated as indicated by a series of apostrophes
(''''''
) and five blank source lines are inserted below the line
in which you entered the line command. The cursor is positioned at the
beginning of the first blank source line.
In the blank source lines, type in text. Lines that are left blank are eliminated from the source when you press ENTER.
The apostrophes are replaced by line numbers indicating that the new text has been incorporated into the source.
When you add lines to the source code of an object, Natural numbers the
added lines in increments of ten. When you insert lines in source code, Natural
automatically renumbers all lines contained in the source code in increments of
ten beginning with 000010
at the first line.
You can change the number of increments by using the system command
RENUMBER
described in the System Commands documentation.
See also Renumbering of Source-Code Line Number References in the Programming Guide.
This section provides instructions for copying text within the current source by using copy and paste functionality. For instructions on copying text from another Natural object into the current source, see To display and copy definitions with SPLIT.
To cut or copy and paste text to a source
Cut or copy text to the clipboard.
Add the number of source lines required to place the text you cut or copied to the clipboard, for example, by proceeding as follows:
Insert a line with the I
line
command.
Enter a character in the new line.
Copy the new line with the
Rn
line command where
n
is the repetition factor.
In the command line, enter the following:
PROTECT ON
This command protects the prefix area to avoid overwriting of source lines if a pasted line contains more than 72 characters.
Position the cursor in the first position of the first source line where you want to paste the text.
Choose the paste function of your terminal emulation or press CTRL+V.
The text placed on the clipboard is pasted in the source lines from the cursor position to the end of the source.
If a pasted line starts with a 6-digit line number copied from a source, you can remove the line number with the following steps.
In the command line, enter the following:
PROTECT OFF
The prefix area is no longer protected and you can enter a line command.
Next to the pasted line that contains a copied line number, enter the following line command:
(7
The line is shifted left by 7 columns thus deleting the line number.
You can use a data window to copy or move text that does not start or end at the beginning or end of a line. Data window functions can be performed by using line commands and/or editor commands.
When you define a window, all text on your screen between start and end of the window become part of the window.
This section provides an example of defining and moving text with a data window by using either line commands or corresponding editor commands.
The example refers to the text shown in Step 1 and assumes that you
want to move the whole sentence starting Note that when...
(line
80) to follow the first sentence of the displayed text ending ...copy
operations
(line 30).
To define and move a window using line commands
>> -----------Columns 001 072 << Text WINEX Lines 10 User MMO Command ===> Mode Report Lib SAGTEST ****** ****************************** top of data ***************************** 000010 Copy a Window with Text 000020 000030 You can specify a window with text for move or copy operations. This 000040 allows you to copy or move text that does not start or end at the 000050 beginning or end of a line. This function can be performed using 000060 line commands and/or editor commands. 000070 000080 Below are some examples of copying windows with text. Note that when 000090 you define a window, all text on your screen between start and end of 000100 the window become part of the window. Available line commands are: ****** **************************** bottom of data **************************** Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12--- Help Save Exit Run Rfind Stow Check Home Undo Canc |
Type the line command WS
in line 80, the
first line of text to be moved, place the cursor in the required column
(N
of the word Note
) and press ENTER.
The message WS55
appears in the prefix area of line 80,
indicating the column number selected:
>> ----------Block is pending << Text WINEX Lines 10 User MMO Command ===> Mode Report Lib SAGTEST ****** ****************************** top of data ***************************** 000010 Copy a Window with Text 000020 000030 You can specify a window with text for move or copy operations. This 000040 allows you to copy or move text that does not start or end at the 000050 beginning or end of a line. This function can be performed using 000060 line commands and/or editor commands. 000070 WS55 Below are some examples of copying windows with text. Note that when 000090 you define a window, all text on your screen between start and end of 000100 the window become part of the window. Available line commands are: ****** **************************** bottom of data **************************** Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12--- Help Save Exit Run Rfind Stow Check Home Undo Canc |
Type the line command WE
in line 100, the
last line of text to be moved, move the cursor to the last column to be moved
(full stop (.
) after window
) and press
ENTER.
The message WE37
appears in the prefix area of line
100:
>> ----------Block is pending << Text WINEX Lines 10 User MMO Command ===> Mode Report Lib SAGTEST ****** ****************************** top of data ***************************** 000010 Copy a Window with Text 000020 000030 You can specify a window with text for move or copy operations. This 000040 allows you to copy or move text that does not start or end at the 000050 beginning or end of a line. This function can be performed using 000060 line commands and/or editor commands. 000070 WS55 Below are some examples of copying windows with text. Note that when 000090 you define a window, all text on your screen between start and end of WE37 the window become part of the window. Available line commands are: ****** **************************** bottom of data **************************** Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12--- Help Save Exit Run Rfind Stow Check Home Undo Canc |
Type the line command WM
in line 30 (the
text will be moved to the following line, line 40), and move the cursor to the
column at which line 30 is to be split (the blank before the word
This
). Press ENTER.
The specified text section is moved:
>> -----------Columns 001 072 << Text WINEX Lines 13 User MMO Command ===> Mode Report Lib SAGTEST ****** ****************************** top of data ***************************** 000010 Copy a Window with Text 000020 000030 You can specify a window with text for move or copy operations. 000040 Note that when 000050 you define a window, all text on your screen between start and end of 000060 the window become part of the window. 000070 This 000080 allows you to copy or move text that does not start or end at the 000090 beginning or end of a line. This function can be performed using 000100 line commands and/or editor commands. 000110 000120 Below are some examples of copying windows with text. 000130 Available line commands are: ****** **************************** bottom of data **************************** Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12--- Help Save Exit Run Rfind Stow Check Home Undo Canc |
You can achieve the same result described in the instructions above by using the command sequence indicated below.
To define and move a window using editor commands
Type in the text shown in Step 1 above.
In the command line, enter the following:
WINDOW 80 100 55 37;MWINDOW 30 64
The specified text section is moved as illustrated in Step 4 above.
This section provides instructions for finding and replacing a character string in the current source.
To find and replace a character string in a source
Search for a string by using the following editor command:
FIND 'string'
where string
is any
alphanumeric character string.
The first occurrence of the specified string is found.
Replace the string found by using the following command:
CHANGE 'string' 'new-string'
Or:
Search for the next occurrence of the string by pressing
PF5.
Depending on the command used, the first occurrence of the string is either replaced or the next occurrence (if any) of the string is found.
Replace the string found by pressing PF17.
Or:
Search for the next occurrence of the string by pressing
PF5.
Depending on the PF key used, the next occurrence of the string is either replaced or the next but one occurrence (if any) of the string is found.
You can format source code by indenting source lines. Indentation is performed differently for sources created in reporting mode than for sources created in structured mode.
To format source code
In the command line, enter the following system command:
STRUCT
The lines in the source code are indented.
For details, see STRUCT
in the
System Commands documentation.
To check the current source code for syntax errors
On the editor screen, press PF9.
Or:
In the command line, enter the following:
CHECK
The source code currently contained in the source work area is checked for syntax errors. If a syntax error is detected, an appropriate error message appears indicating the line number affected and the erroneous definition.