Natural for Visual Studio Code 1.2.1 | The Natural Source Editor | Using Natural Line Number References
 
Using Natural Line Number References
A Natural statement can refer to an earlier statement by its line number. The reference consists of exactly four digits enclosed in parentheses. In the following source, the DISPLAY statements refer to their corresponding READ loops: the outer READ on line 9 and the inner READ on line 11.
9 READ (10) EMPLOYEES BY CITY
10 DISPLAY NAME (0009)
11 READ (10) EMPLOYEES BY CITY
12 DISPLAY NAME (0011)
13 LOOP
14 LOOP
Because such a reference identifies a specific line, it becomes invalid if a line is inserted or deleted above the referenced statement. When you edit a Natural source, its line number references are therefore updated immediately, in the same way as in the NaturalONE source editor.
For example, inserting a new line after the outer READ moves the inner READ from line 11 to line 12, and the corresponding reference (now on line 13) is updated from (0011) to (0012):
9 READ (10) EMPLOYEES BY CITY
10
11 DISPLAY NAME (0009)
12 READ (10) EMPLOYEES BY CITY
13 DISPLAY NAME (0012)
14 LOOP
15 LOOP
The notations (nnnn), (nnnn,, and (nnnn/ are recognized. A line number reference always consists of four digits.
Updating a line number reference is part of the same undo operation as the edit that caused the update. A single Ctrl+Z therefore undoes both the edit and the corresponding renumbering.
What Is Not Changed
Not every four-digit number in parentheses is a line number reference, and not every line number reference is updated:
*Limits and indexes, such as 1000 in READ (1000) EMP or 0022 in IF #A1 = MASK(0022). If the value is greater than the number of the line on which it occurs, it cannot refer to an earlier statement and is therefore left unchanged.
*Line number patterns inside constants, such as WRITE 'see (0014) above'. Such a pattern is part of the text produced by the program, and editing the source must not change the program output.
*References to deleted lines. These retain their original values rather than being redirected to a neighboring line, so that they remain recognizable as references to lines that no longer exist.
*Data areas (.NSL, .NSA, .NSG), where parentheses contain formats, array bounds, and INIT values rather than line number references. Maps and DDMs are not changed either.
*Sources that are replaced as a whole, for example, when a file is reverted or has changed on disk. The line number references in the replacement text belong to that version of the source and are therefore left unchanged.
References inside comments are updated, so that a comment referring to a statement continues to point to that statement.
Line Number Reference Preference
The automatic updating of line number references is controlled by the natural.editor.renumber.lineReferences preference (default: true);. See also Preparing the Workspace. When this preference is disabled, line number references remain unchanged.