(edited 28-Jun) (Special Operations for Programmers\prog_chap)

(Special operations for programmers) (Operations for programmers) (Programmers, operations for) Chapters (work_chap\VALUE) through (insert_chap\VALUE) describe KED operations you can use to create and edit any kind of text file. This chapter describes some operations you can use for program development. (UNNUMBERED) Three ways to insert escape characters ((insertescape_sec)) For MACRO--11 and MACRO--32 programs, a renumbering operation ((reord_sec)) that renumbers your local symbols For any program you write in a structured language, a structured tab operation ((struc_sec)) that can: (SIMPLE) Create multiple levels of indentation Insert statements in a structured program Change the indentation level of a group of statements Rewrite indentations to use the most efficient combination of tabs and spaces

Although the KED features described in this chapter are robust in design, some are specialized in nature and, therefore, performed infrequently. For that reason, you should consider closing and reopening a file and thereby making a backup copy, before performing special operations on the file. (Inserting Escape Characters\insertescape_sec)

(Insertingescape characters) (Escape characters, inserting) KED gives you three ways to insert the escape character. (ESC keyboard key) (Keyboard keysESC) (numbered) On all terminals, press (CTRL/[) (CTRL and left square bracket) twice.

KED displays the pi ((pi)) symbol. On many terminals, press (ESC) twice.

KED displays the pi ((pi)) symbol. On all terminals, use the SPECINS function. (Keypad keysSPECINS) (SPECINS function) (FunctionsSPECINS) (alphabetic) Press (GOLD). Type the ASCII decimal equivalent of the escape character (27). Press (GOLD) and (SPECINS).

KED displays the pi ((pi)) symbol.

In other words: (simple) ((CTRL/[) (CTRL/[)) or ((ESC) (ESC)) or ((GOLD) (27) (GOLD) (SPECINS))

You can use the following escape characters for the keypad functions listed. Two ways to insert the escape equivalents in a file are: (unnumbered) You can insert an escape character as described above and then type the indicated characters. You can issue a single escape character by pressing (CTRL/[) or (ESC) once, press (CTRL) and, while pressing it, press the function key you want to insert. For example, to insert the ADVANCE function:

(CTRL/[) (CTRL/(x)) (where (x) is the ADVANCE function key)

All functions on the keypad can be inserted in that manner. (Keypad Function Escape Equivalents\func_esc_sec) (3\16\18) (Keypad Function\Escape Equivalent\Operation) (ADVANCE\(pi)Ot\Changes the direction of cursor movement to the right and downward.

Enters a search model, specifies a search direction, and starts a search.) (APPEND\(pi)Oy\Deletes selected text and stores it at the end of the paste buffer.) (first) (BACKUP\(pi)Ou\Changes the direction of cursor movement to the left and upward.

Enters a search model, specifies a search direction, and starts a search.) (BLINE\(pi)Op\Moves the cursor to the beginning of a line.) (BOTTOM\(pi)Ot\Moves the cursor to the end-of-file marker.) (CHAR\(pi)Os\Moves the cursor to the next or preceding character.) (CHNGCASE\(pi)OP(pi)Oq\In selected text, changes all lowercase letters to uppercase and all uppercase letters to lowercase.

Changes the case of letters in a search target.

In unselected text, changes the case of the cursor's character.) (COMMAND\(pi)OP(pi)Ow\Displays the (Command:) prompt, which allows specification of a command from the keyboard.) (CUT\(pi)Ov\Deletes selected text and stores it in the paste buffer.) (DELCHAR\(pi)Ol\Deletes the cursor's current character and stores it in the character buffer.) (DELEOL\(pi)OP(pi)Or\Deletes to the next line terminator and stores the string in the line buffer.) (DELLINE\(pi)OS\Deletes through the next line terminator and stores the string in the line buffer.) (DELWORD\(pi)Om\Deletes to the first character of the next word and stores the string in the word buffer.) (ENTER\(pi)OM\Executes a command and erases the command and the command prompt.

Enters a search model without starting a search. FINDNEXT will start the search.

Restores the display after the HELP function has been used.) (EOL\(pi)Or\Moves the cursor to a line terminator.) (FILL\(pi)OP(pi)Or\Reformats the lines in selected text.) (FIND\(pi)OP(pi)OR\Displays the (Model:) prompt, which allows the specification of a search string.) (FINDNEXT\(pi)OR\Uses the keypad directional mode to search for another occurrence of a target that matches a search model.

Starts a search after the ENTER function has been used.) (GOLD\(pi)OP\Specifies the lower function of the two functions on a keypad key.

Allows the use of the GOLD keyboard-key functions.) (HELP\(pi)OQ\If an error occurred, displays an error message.

If no error occurred or if KED is displaying an error message, displays a keypad diagram.

If the keypad diagram is displayed, displays summaries of KED commands and functions.) (OPENLINE\(pi)OP(pi)Op\Breaks the current line by inserting a new-line terminator at the cursor's right.) (PAGE\(pi)Ow\Moves the cursor to the top of a page. The page default is a form-feed character.) (PASTE\(pi)OP(pi)Ov\Inserts text from the paste buffer.) (REPLACE\(pi)OP(pi)Oy\Deletes and discards selected text.

Deletes and discards a search target and inserts a character string from the paste buffer.) (RESET\(pi)OP(pi)On\Cancels a GOLD function or a text selection.) (SECTION\(pi)Ox\Moves the cursor to the top of a section. The section default is 16 lines.) (SELECT\(pi)On\Marks one end of selected text.) (SPECINS\(pi)OP(pi)Os\Inserts a nonprinting character.) (SUBSTITUTE\(pi)OP(pi)OM\When the cursor is at a search target, completes the REPLACE function and then the FINDNEXT function.) (TOP\(pi)OP(pi)Ou\Moves the cursor to the top of a file.) (UNDELCHAR\(pi)OP(pi)Ol\Inserts a character from the character buffer.) (UNDELLINE\(pi)OP(pi)OS\Inserts a character string from the line buffer.) (last) (UNDELWORD\(pi)OP(pi)Om\Inserts a character string from the word buffer.) (WORD\(pi)Oq\Moves the cursor to the beginning of a word.) (Renumbering MACRO--11 and MACRO--32 Local Symbols\REORD_SEC)

(Renumbering MACRO--11 local symbols) (Renumbering MACRO--32 local symbols) (MACRO--32) (MACRO--11 local symbolsrenumbering) (Local symbols, MACRO--11renumbering) (SymbolslocalMACRO--11) (SymbolslocalMACRO--32) Good programming practice requires that local symbols within each local symbol block (LSB) begin with the symbol 10$ and continue in increments of ten---20$, 30$, 40$, and so on. In the course of program development, that order can be upset and the symbols have to be renumbered.

You can use the LOCAL command to renumber your MACRO--11 or MACRO--32 local symbols, but you must observe some rules and restrictions. (LOCAL Command)

(LOCAL start increment command) (CommandsLOCAL start increment) The LOCAL command lets you renumber the local symbols in your MACRO--11 source program. (NUMBERED) Press (GOLD) and (COMMAND). Type: (LOCAL [start] [increment])

(start) is the optional starting value. You can type any whole number from 1 to 32767. The default is 10.

(increment) is the optional incrementing value. You can type any whole number from 1 to 32767. The default is 10. Press (ENTER).

KED renumbers your local symbols. KED also renumbers all references to each local symbol, including references within comments.

In other words: (simple) ((GOLD) (COMMAND) LOCAL [start] [increment] (ENTER))

For example, to renumber all the local symbols in your source program, beginning with 100$ and incrementing each subsequent symbol by 100: (simple) ((GOLD) (COMMAND) LOCAL 100 100 (ENTER))

To renumber several LSBs that use the same local symbols: (NUMBERED) Renumber each LSB separately, using a starting local symbol value that will not overlap any values in the other LSBs. Combine the LSBs in your program. Renumber the combined LSB.

For example, to renumber the local symbols within two LSBs, use a procedure such as the following. (numbered) Renumber one of the LSBs with the LOCAL 1000 command. Combine the LSBs by using the CUT and PASTE operations. Renumber the combined LSB with the LOCAL 10 command. (Rules and Restrictions)

(Restrictions and rules for renumbering MACRO--11 local symbols) (Renumbering MACRO--11 local symbolsrules and restrictions) (MACRO--11 local symbolsrenumberingrules and restrictions) (Local symbols, MACRO--11rules and restrictions) (Symbolslocalrules and restrictions) When renumbering local symbols, observe the following rules and restrictions. (UNNUMBERED) Do not abort the renumbering operation by pressing (CTRL/C). Local symbol renumbering alignment is destroyed, making the file unusable. Large local symbol blocks can take some time to renumber. Begin renumbering an LSB at the program line below the directive that enables the LSB you are renumbering. Place the cursor on that line and issue the LOCAL command. If an LSB is divided into pages with form-feed characters, place the cursor at or above the first form-feed character in the block before you use the LOCAL command. Otherwise, KED signals you and displays: Valid start of LSB not found. KED recognizes (detects and changes) only local symbols that have the form: [white_space]number$:

(white_space) is a line terminator and one or more optional spaces or tabs.

(number) is the local symbol number. It cannot be any longer than six digits.

For example, this local symbol is formatted correctly. 30$: KED recognizes only references to local symbols that have the form: character number$

(character) is any non-Radix-50 character.

(number) is the local symbol number.

For example, this local symbol reference is formatted correctly. BCS 30$ KED recognizes only the following LSBs: (unnumbered\--) LSBs that are explicitly included in source code. LSBs that are part of macro expansions are not recognized. LSBs that begin with an .ENABL LSB, .ENABLE LSB, or .ENABLE LOCAL_BLOCK directive and end with a .DSABL LSB, .DISABLE LSB, or .DISABLE LOCAL_BLOCK directive. Renumbering is also terminated in an LSB when KED finds another directive to enable an LSB before finding a directive to disable the LSB; the second enabling directive is treated as a disabling directive. LSBs that begin with .ENABLE LOCAL_SYMBOL_BLOCK and with .DISABLE LOCAL_SYMBOL_BLOCK with MACRO--32. LSBs that begin with a nonlocal symbol definition and end with another nonlocal symbol definition, an .ENABL LSB directive, or a .DSABL LSB directive.

MACRO--11 accepts other LSBs, but KED cannot recognize them. For example, KED cannot recognize the .PSECT directive as the end of an LSB, even though it is a valid LSB terminator for MACRO--11 programs. Therefore, KED continues to renumber the local symbols below a .PSECT directive until it finds an LSB terminator it recognizes. (Using the Structured Tab Operation\STRUC_SEC)

(Usingstructured tab operation) (Structured tab operation, using) (Tab operation, structured) (Operationsstructured tab) KED's structured tab operation lets you: (UNNUMBERED) Create multiple levels of indentation ((crelev_sec)) Insert statements in a structured program ((ins_sec)) Change the indentation level of a group of statements ((cha_sec)) Rewrite indentations to use the most efficient combination of tabs and spaces ((rew_sec))

Those features are enabled by the SET TABS command described in (indentvalue_sec). (Creating Multiple Levels of Indentation\crelev_SEC)

(Creatingmultiple levels of indentation) (Indentation levels, creating) To create a program with multiple levels of indentation: (NUMBERED) Specify an indentation value (the number of columns separating each level of indentation) and initialize the level counter with a value of 1 to indicate the first level of indentation. That operation also enables all the structured tab features. Increment or decrement the level counter to specify the level of indentation at which you want to type in code. That operation moves the indentation right or left. (Specifying an Indentation Value and Initializing the Level Counter (Enabling Structured Tab Features)\indentvalue_sec)

(Initializing level counter and specifying indentation value) (Specifyingindentation value and initializing level counter) (Indentation value, specifying) (Indentation level counter, initializing) (Level counterindentation, initializing) (Counter indentation level, initializing) To specify an indentation value and initialize the level counter at 1: (SET TABS indent command) (CommandsSET TABS indent) (NUMBERED) Press (GOLD) and (COMMAND). Type: (SET TABS [indent])

(indent) is any whole number from 1 to 32767 (8 or a multiple of 8 will ensure the correct alignment of statement comments if they are preceded by horizontal tabs). The default is 4. Press (ENTER).

KED stores the indentation value and sets the level counter to 1.

In other words: (simple) ((GOLD) (COMMAND) SET TABS [indent] (ENTER))

Once you enter the SET TABS command, you can type in code at the first level of indentation. (NUMBERED) Move the cursor to the beginning of a new line. Press (TAB).

KED advances the cursor to the first level of indentation. Type in your code.

For example, to specify an indentation of eight columns and initialize the level counter: (simple) ((GOLD) (COMMAND) SET TABS 8 (ENTER)) Move the cursor to a new line. ((TAB)) KED advances the cursor eight columns to the first level of indentation. Type in code at that level.

If you do not move the cursor to the beginning of a new line (if a space or horizontal tab is to the left of the cursor) before you press (TAB), KED responds as if the structured tab features were disabled.

To cancel the indentation value and the initialization of the level counter: (simple) (SET NOTABS command) (CommandsSET NOTABS) (GOLD) (COMMAND) (SET NOTABS) (ENTER)

That command disables all structured tab features, including the TABS ADJUST commands (Sections (cha_sec\value) and (rew_sec\value)). (Incrementing and Decrementing the Level Counter (Moving the Indentation Right and Left))

Incrementing the level counter moves your indentation to the right. Decrementing the level counter moves your indentation to the left. (Incrementing Level Counter---Moving Indentation Right)

(Incrementing level counter, moving right) (Level counterincrementing, moving right) (Moving indentation right, incrementing level counter) (Indentationmoving right, incrementing level counter) (Movingindentation) To move the cursor to higher levels of indentation (increment the level counter): (NUMBERED) Issue the SET TABS command as described in (indentvalue_sec). Press (GOLD). (E keyboard key) (Keyboard keysE) (GOLD E function) (FunctionsGOLD E) Type: (E)

KED increments the level counter by 1. To continue incrementing the level counter, repeat steps 3 and 4. Press (TAB).

KED moves the cursor to the level you specified. Type a line of code and press (RETURN).

KED moves the cursor to the beginning of the next line. To begin another line of code at the same indentation level, press (TAB).

In other words: (simple) ((GOLD) (COMMAND) SET TABS [indent] (ENTER)) ((GOLD) (E)) ((TAB) line-of-code (RET))

If you do not move the cursor to the beginning of a new line (if a space or horizontal tab is to the left of the cursor) before you press (TAB), KED responds as if the structured tab features were disabled. (Decrementing Level Counter---Moving Indentation Left)

(Decrementing level counter, moving left) (Level counterdecrementing, moving left) (Moving indentation left, decrementing level counter) (Indentationmoving left, decrementing level counter) (Movingindentation) To move the cursor to lower levels of indentation (decrement the level counter): (NUMBERED) Issue the SET TABS command as described in (indentvalue_sec). Press (GOLD). (D keyboard key) (Keyboard keysD) (GOLD D function) (FunctionsGOLD D) Type: (D)

KED decrements the level counter by 1. To continue decrementing the level counter, repeat steps 3 and 4. Press (TAB).

KED moves the cursor to the level you specified. Type a line of code and press (RETURN).

KED moves the cursor to the beginning of the next line. To begin another line of code at the same indentation level, press (TAB).

In other words: (simple) ((GOLD) (COMMAND) SET TABS [indent] (ENTER)) ((GOLD) D) ((TAB) line-of-code (RET))

If you do not move the cursor to the beginning of a new line (if a space or horizontal tab is to the left of the cursor) before you press (TAB), KED responds as if the structured tab features were disabled. (Inserting Statements in a Structured Program\INS_SEC)

(Program, structuredinserting statements) (Insertingstatements in structured program) (Statements in structured program, inserting) (Structured program statements, inserting) During the development of a program, you may want to insert additional statements in an indented section of existing statements. (NUMBERED) Issue the SET TABS command as described in (indentvalue_sec). Move the cursor to the indentation level of the section in which you want to insert additional statements. Press (GOLD). (A keyboard key) (Keyboard keysA) (GOLD A function) (FunctionsGOLD A) Type: (A)

KED sets the indentation level. Move the cursor to the left margin. Press (TAB).

KED moves the cursor to the indentation level you set with the A key.

KED calculates the level of indentation by dividing the indentation value (which you set with the SET TABS command) into the number of the column where the cursor is located. The indentation value must divide evenly into the column number. If it does not, KED signals that an error occurred and ignores its calculation. If you press (HELP), KED displays: TAB indent value wrong for align.

In other words: (simple) (GOLD) (COMMAND) (SET TABS [indent]) (ENTER) Move the cursor to the indentation level. (GOLD) (A) Move the cursor to the left margin. (TAB)

For example, to add additional statements to a group of statements at the fourth level of indentation when the indentation value is 5: (simple) Move the cursor to the column in which the statements begin. (GOLD) (A) Since the cursor is at column 20, KED calculates the indentation level as 4. Move the cursor to the left margin. (TAB) KED moves the cursor to the fourth level of indentation. (Changing the Indentation Level of a Group of Statements\CHA_SEC)

(Changingindentation level of statements) (Indentation level of statements, changing) (Statements, changing indentation level) In developing a program you may want to change the indentation level of a group of statements. (NUMBERED) Issue the SET TABS command as described in (indentvalue_sec). Move the cursor to the left margin of the line containing the first statement in the group. Press (SELECT). Move the cursor to the character following the last statement in the group. Press (GOLD) and (COMMAND). (TABS ADJUST level command) (CommandsTABS ADJUST level) Type: ([TABS] ADJUST [level])

(level) is the number by which you want to increment or decrement the level counter. To increment the level counter (obtain a higher level of indentation), type any number from +1 to +50. To decrement the level counter (obtain a lower level of indentation), type any number from --1 to --50. The default is 0 (see (rew_sec)). Press (ENTER).

KED reformats all the selected lines to begin at the level you specified.

In other words: (simple) ((GOLD) (COMMAND) SET TABS [indent] (ENTER)) Select the group of statements. ((GOLD) (COMMAND) ADJUST [level] (ENTER))

When you adjust the indentation of selected lines, KED cannot maintain the position of comments that are to the right of executable statements in the selection, unless the indentation value you used in enabling structured tabs ((indentvalue_sec)) is 8 or a multiple of 8 and the comments are preceded by tab characters.

To cancel the SET TABS command: (simple) ((GOLD) (COMMAND) SET NOTABS (ENTER)) (Rewriting Indentations to Use the Most Efficient Combination of Tabs and Spaces\REW_SEC)

(Indentations, rewriting to use efficient combination of tabs and spaces) (Usingtabs and spaces efficiently) (Usingefficient combination of tabs and spaces) (Tabs and spaces, using efficient combination) (Spaces and tabs, using efficient combination) KED can replace the existing combination of tabs and spaces at the beginning of text lines with the most efficient combination possible, perhaps reducing the amount of media required to store the file. The indentation itself is not changed. This feature is useful only with text lines not written with the aid of structured tabs and should not be used with text lines that use structured tabs.

When using structured tabs to indent a line, KED: (simple) Inserts a tab character for every eight columns in the indentation Fills in any remaining columns with single spaces

To optimize the indentation of lines that you typed in without the aid of structured tabs: (numbered) Issue the SET TABS command as described in (indentvalue_sec). Move the cursor to the left margin of the first line you want to optimize. Press (SELECT). Move the cursor to the left margin of the line following the last line you want to optimize. Press (GOLD) and (COMMAND). (TABS ADJUST 0 command) (CommandsTABS ADJUST 0) Type: ([TABS] ADJUST [0]) Press (ENTER).

KED does not change the amount of indentation of the lines you selected, but replaces the spaces and tabs at the beginning of each line with the most efficient combination of spaces and tabs possible for that amount of indentation.

In other words: (simple) ((GOLD) (COMMAND) SET TABS [indent] (ENTER)) Select the lines to be optimized. ((GOLD) (COMMAND) ADJUST (ENTER))

When you adjust the indentation of selected lines, KED cannot maintain the position of comments that are to the right of executable statements in the selection, unless the indentation value you used in enabling structured tabs ((indentvalue_sec)) is 8 or a multiple of 8 and the comments are preceded by tab characters.

To cancel the SET TABS command: (simple) ((GOLD) (COMMAND) SET NOTABS (ENTER)) (Examples of the Structured Tab Operation)

This section provides examples of the structured tab operation in a short section of a FORTRAN program. By creating a new file and then following the instructions for each step, you can see the processes that take place. (numbered) Enable structured tabs and set the basic indentation to 4. (GOLD) (COMMAND) SET TABS 4 (ENTER) With the cursor at column 1, type: (TAB) DO 100 NUM = START, FINISH (RET)

KED indents the statement to column 5 with 4 spaces, because the basic indentation is 4 and the level counter is 1. The indentation is created with spaces, because it is not large enough to permit any tab characters to be used. Increase the level counter to 2. (GOLD) E With the cursor at column 1, type: (TAB) SUM = 0 (RET) (TAB) SUM = SUM + ARRAY (NUM) (RET) 100 (TAB) CONTINUE (RET)

The programming error with the SUM = 0 statement will be corrected in a later step.

KED indents the first two statements to column 9 with a tab character (equivalent to 8 spaces), because the level counter is now 2. Each indentation is created with a tab character, because KED calculates that the tab character will have the same effect as 8 spaces. Decrease the indentation. (GOLD) D With the cursor at column 1, type: (TAB) TYPE *, SUM (RET) (TAB) END (RET)

KED indents the statements to column 5 by inserting 4 spaces, because the level counter is now 1.

Your statements should now look like this. DO 100 NUM = START, FINISH SUM = 0 SUM = SUM + ARRAY (NUM) 100 CONTINUE TYPE *, SUM END With the cursor at column 1 of the DO statement, indent the six statements 4 additional spaces. (SELECT) (GOLD) (BOTTOM) (GOLD) (COMMAND) TABS ADJUST +1 (ENTER)

KED increases each indentation by 4 columns, by calculating and inserting the most efficient combination of tabs and spaces for each statement. The SUM = 0 statement is inside the DO loop. Fix that error by moving the SUM = 0 statement above the DO statement.

Your statements should now look like this. SUM = 0 DO 100 NUM = START, FINISH SUM = SUM + ARRAY (NUM) 100 CONTINUE TYPE *, SUM END With the cursor at column 1 of the SUM = 0 statement, decrease the indentation of the SUM = 0 statement. (SELECT) (ADVANCE) (BLINE) (GOLD) (COMMAND) TABS ADJUST -1 (ENTER) With the cursor on C of the word CONTINUE, insert a new statement in the DO loop and align it with the other statements in that loop. (alphabetic) Set the level counter properly. (GOLD) A Move the cursor to the beginning of the 100 CONTINUE statement and create an open line for the new statement. (BACKUP) (BLINE) (GOLD) (OPENLINE)

Your statements should now look like this. SUM = 0 DO 100 NUM = START, FINISH SUM = SUM + ARRAY (NUM) 100 CONTINUE TYPE *, SUM END Type the new statement. (Tab) IF (ARRAY(NUM) .LT. 0) TYPE *,'Low value at ',NUM

KED indents the new statement to column 13. The total indentation is the equivalent of 12 spaces (3 times 4), because the GOLD A function set the level counter to 3 and the basic indentation is 4.

Your statements should now look like this. SUM = 0 DO 100 NUM = START, FINISH SUM = SUM + ARRAY (NUM) IF (ARRAY(NUM) .LT. 0) TYPE *,'Low value at ',NUM 100 CONTINUE TYPE *, SUM END