The Edit Mode

,







The following is a summary of the edit commands:
Command Function
ENTER Moves the edit pointer to the next line. Causes
a command to execute.
+ number Moves the edit pointer ahead number lines.
+ * Moves the edit pointer to the last line.
-number Moves the edit pointer back number lines.
-* Moves the edit pointer to the first line.
text Inserts an unnumbered text line before the
current line.
ntext Inserts the line numbered n in its correct _
numeric position.
n Moves the edit pointer to the line numbered n.
clstrllstr2/ Changes the next occurrence of strl to str2.


BASIC09 Reference

Command Function

c*lstrllstr2l Changes all occurrences of ctrl to str2.
d Deletes the current line.
d* Deletes all the lines in the procedure.
1 Lists the current procedure line.
1* Lists all the procedure lines.
q Terminates the edit session.
r Renumbers lines beginning at the current line
in increments of 10.
r* Renumbers all lines in increments of 10.
r n Renumbers lines beginning at Line n in
increments of 10.
r n1 n2 Renumbers lines beginning at Line n1 in
increments of n2.
s /string/ Searches for the first occurrence of string.
s* /string/ Searches for all occurrences of string.

Using the Editor

The easiest way to understand the edit commands is to use them. The following sections show you the functions of BASIC09 edit mode.

The manual uses line numbers in the following procedure to acquaint you with all the functions of the editor. Remember, however, line numbers are not required with BASIC09. Procedures and programs without line numbers are shorter, faster, and easier to read.

First, you need a procedure with which to work. Position yourself in the system mode. Then, type this line:



4-2


Now, type the following. (Remember, the small rectangle represents a space.)

0100 DIM PHRASES(30):STRING
01 20 FOR T-1 TO 30
0130 READ PHRASES(t)
01 40 NEXT T
0160 PRINT
01 70 F I RST-RND(1 0
0180 SECOND=RND(9)+1 1
0190 THIRD=RND(9)+21
0200 PRINT PHRASESCFIRST);
0210 PRINT PHRASES(SECOND);
0220 PRINT PHRASES(THIRD);
0240 PRINT
030 0 DATA "Love[]" , "An orange[]",
" H uma n i t y0" , " A k i 5 5F1"
0310 DATA "A dark cloudy","A goose feather[]",
"A Pop5icle0"
0320 DATA "Home cooking[]" ,"Cold pizza[]",
"Rock n' Ro 1 10"
0330 DATA "i5 charming like[]","makes me dream of0"
0340 DATA "i5 a5 sticky asp","can ooze
like[]","Sme115 like[]"
0350 DATA "can be as tough to forget a50","can
hurt like[]"
0360 DATA "can be a5 cynical a50","makes a mockery
of0_
0370 DATA "drives me a5 crazy a50"
0380 DATA "a sticky lollipop.","a web of
intrigue."
0390 DATA "castor oil.","a chocolate bath.","a
broken toe."
0400 DATA "honey and things.","personal
defeat .", "a wet diaper."
0410 DATA "Strange happenings.","a pennyle55
purse."

When you finish typing the procedure, type q ENTER to return to the system mode. Now you can test the program by typing either:

run ENTER or



4-3
BASIC09 Reference

After trying the procedure, return to the edit mode by typing e ENTER .


After displaying the procedure's name, the editor displays Line 100 preceded by an asterisk. The asterisk lets you know which line is the current line (or the line at which the edit pointer is located).


Searching Through a Procedure

You can examine a procedure in three ways:







When you use either of the first two methods, the line you select to display becomes your current line. When you use the third method, the current line does not change.


Using ENTER

If you are still positioned at Line 100, but want to examine the first line of data, Line 300, press ENTER 12 times to move down.


Using the Plus Sign to Move Forward

Another method of moving to a specific line is to type a plus sign followed by the number of lines you need to advance to get there. Positioned at Line 100, you can type:




Whether you press ENTER or use the plus sign, the last line displayed is now your current line.


4-4
The Edit Mode / 4

Accessing a Line Using the Line Number

The third way to move to a particular line is to type the line number, followed by ENTER . For instance, to jump back to Line 100, type:



The editor displays Line 100 and makes it your current line.

Using the Minus Sign to Move Backward

In the same manner that you move forward in the procedure using the plus sign, you can move backward using the minus sign, or hyphen.

Type 3 0 0 ENTER to return to Line 300. To display Line 240 and make it your current line, type:



To display Line 190 and make it your current line, type:



The Global Symbol

The BASIC09 editor also makes use of the asterisk as a global symbol. For instance, following a command with an asterisk causes that command to affect the entire procedure.

This feature lets you move quickly to the beginning and end of the procedure. To return to Line 100, the first line, type:



To move to the end of the procedure, past all the numbered lines, type:




BASIC09 Reference

Using LIST

The LIST command lets you select one or more lines for display
on your screen. To see this, make the first line your current line, ~`
then type:

    1 ENTER


To list one or more lines, type the LIST command followed by the number of lines you want displayed. For instance, typing 15

ENTER causes the current line and four others to appear on the screen, as shown in the following sequence of commands and the resulting display:


    - * ENTER


    15 ENTER

    PROCEDURE Prose

    100 DIM PHRASESC30): STRING

    120 FOR T=1 TO 30

    13OREAD PHRASESCT)

    140 NEXT T

    160 PRINT


You can also use LIST with the BASIC09 global symbol, *. Typing an asterisk after the LIST command produces a listing of the entire procedure.


Deleting Lines

Earlier, the manual showed that you can delete the current line by typing d ENTER . Because this is such a simple process, be sure you don't do it by accident. Removing the wrong line, or too many lines, is very frustrating in a complex procedure.


You can also remove a group of lines from a procedure by typing d, followed by the number of lines you want to delete. This command deletes the current line and specified following lines. Again, be careful.


You can remove all of the lines in a procedure by using the global symbol, *. Typing d * ENTER erases all procedure text. However, the procedure name still resides in the workspace. To delete an entire procedure, including the name, use the KILL command from the system mode.


4-6
The Edit Mode / 4

If you decide you don't like the nouns used in the DATA lines of the Prose procedure, erase all of the DATA lines containing nouns (Lines 300-320) and replace them. To do so, make Line 300 your current line by typing:


    3 0 0 ENTER


Then type:

    d ENTER


Line 300 disappears and Line 310 takes its place as the current line.


An alternate method of deleting the DATA lines uses only one command. To delete Lines 300 through 410, follow the DELETE command with the number of lines you want to remove in this case, three:


    d 3 ENTER


Lines 300, 310, and 320 disappear. Line 330 becomes the current line. Move back a line to check that the deletions worked. The line numbers now skip from 240 to 330.


Now, you need new nouns for the procedure. Type them in the same style as the old lines, such as:


    0300 DATA "A Telephone0,"A tickle0",

    "A gir10","A boy0"

    031 5 DATA "Had 1 uc k0" "MoneyO","A bad betO",

    "A lumpy bedO"

    0320 DATA "A deep thought0","Sunlight0"


Save a copy of your procedure to disk by exiting the editor and using the SAVE command. Then return to the edit mode and try the global delete by typing:


    d * ENTER


Changing Text

Using CHANGE tells the editor to search for existing text and replace it with new text. CHANGE, like DELETE, can easily cause unwanted results if you are not careful.


                                4-?

BASIC09 Reference

The CHANGE command requires that you use delimiters to separate the command from the search text, and to separate the search text from the new text. You can select any of the following characters for a delimiter, as long as it does not appear in either the search text or the new text:


    ! # % ^ & () - + = JJ[] 11 ,1 C > , ? / I


Do not use the global symbol (*) for search and replace operations. This manual uses a slash (/) as the CHANGE delimiter.


The following steps outline the correct use of CHANGE:

      1. Position the editor either before or on the line in which you want to make a change.


      2. Type c (for CHANGE). Do not use a preceding space.


      3. Type a delimiter character, such as / .


      4. Type the characters to be changed, following them with the delimiter.


      5. Type the new text, followed by the delimiter.


      6. Press ENTER .


Note: It is a good idea to turn on OS-9's upper- and lowercase function before attempting change or search operations. If you do not, you cannot tell whether the text you want to find is upper- or lowercase, or some combination of the two. If you type the wrong case, the change or search fails.

In case you didn't notice when typing the procedure, Line 410 contains an incorrectly spelled word, pennyless. To correct this error, type the following:


    c/Pennyless/Pennile55/ ENTER


Immediately, the editor displays Line 410, with pennyless changed to penniless.


Suppose you decide to change the number of sentence combinations available in Prose. The procedure now has 30 data entries. If you add five subjects, five verb phrases, and five objects, the procedure also needs other changes (for instance, the DIM statement in Line 100, the loop size in Line 120, and the RND statements in Lines 170 through 190).


4-8
            The Edit Mode / 4


A quick way to change the number 30 in Lines 100 and 120 is to use CHANGE's global function. To change all occurrences of 30 to 45, position the editor at Line 100, and type:


    c*/30/45/ ENTER


Use the CHANGE and global CHANGE functions to adjust the RND statement values in Lines 170, 180, and 190.


As well as making changes, you can use the CHANGE command to quickly delete portions of text within a line. To do this, type delimiters without new text, in this fashion:


    c/Ofeather// ENTER


This command changes the text A g o o s e f e a t h e r in Line 210 t0 A goose.


Searching for Text

The editor's SEARCH command, S, works in the same manner as the CHANGE command. However, SEARCH only requires you to specify a block of text to find.


With SEARCH, you use delimiters to enclose the text to find. To test the function, position the editor at the beginning of text by typing:


    - * ENTER


Now, search for the word phrases, by typing:

    s/phrases/ ENTER


The screen displays:

    *0000 100 DIM phra5e5(30):STRING


To find all occurrences of phrases throughout the procedure, use the global symbol. Type:


    5*/Phra5e5/ ENTER


4-9
BASIC09 Reference

Renumbering Lines

The RENUMBER command, R, reorders all numbered lines and all references to numbered lines. You can give RENUMBER either one or two parameters. The first is the beginning line number. The second is the increment you want. The default increment is 10.


For instance, the Prose procedure line numbers skip from Line 100 to Line 120. You can renumber the entire procedure by moving the editor to Line 100, and then typing:


    r 10 ENTER


To change the numbering to increments of 5, beginning at Line 100, type:


    r 1 0 0 , S ENTER


You can also change line numbering in portions of the procedure. To do this move the editor to the line where you want the new numbering to begin. Then, type in the new parameters. To renumber Line 100 as Line 200 and continue with increments of 10, position the editor at Line 100. Then, type:


    r 2 0 0 , 1 0 ENTER


If you are not positioned at the first line of a procedure, but you wish to renumber all lines, you can use the global symbol to do the job. From anywhere in the procedure, type:


    r * 1 0 0 , 1 0 ENTER


This renumbers the entire procedure in increments of 10.

Adding Lines

There are two ways to add new lines to a procedure. You can:

      Position the editor one line below the position for the new line. Then, type the new line and press ENTER . When inserting lines without numbers, be sure to type a space as the first character of the line to tell the editor that the following text is a new procedure line.


      · Type a new line, giving it a line number that falls between two existing line numbers.


      4-10

The Edit Mode / 4

The following procedure adds more choices to the Prose program. It also adds a feature that lets you press ~n~TER for additional output, rather than having to rerun the procedure. Use the information presented in this section to help you insert the new lines into your program. Because you must change some lines, as well as add lines, the following listing includes the entire procedure.

Referring to the original Prose listing, the lines to change are: 100, 120, 170, 180, and 190.

The lines to add are: 110, 150, 230, 250, 260, 270, 305, 325, 372, 374, 376, 420, 430.

PROCEDURE pro5e2
100 DIM PHRASESC45):STRING
110 DIM RESPONSE:STRING
120 FOR T=1 TO 45
130 READ PHRASESCt)
140 NEXT T
150 REPEAT
160 PRINT
170 FIRST=RNDC15)
180 SECOND=RNDC14)+16
190 THIRD=RNDC 1 4)+31
200 PRINT PHRASESCFIRST);.
210 PRINT PHRASESCSECOND);
220 PRINT PHRASESCTHIRD);
230 PRINT.
240 PRINT
250 PRINT "0000000000Pre55 ENTER f or another
witticism..."
260 INPUT "0000000=Or pre55 the SPACEBAR and pre55
ENTER to end...",RESPONSE
270 UNTIL RESPONSE),""
300 DATA "LoveO","An orange[]","Humanity[]",
"A k i 5 50"
305 DATA "A computer[]","A book[]", "Mi5ery0" -
310 DATA "A dark cloud[]","A goose feather[]",
"A Pops i c 1 e0"
320 DATA "Home cook ing[]","Cold pizza[]",
"Rock n' Ro 1 10"
325 DATA "Snow in JuneO","A gla55 hourse0"
330 DATA "i5 charming likep","makes me dream of0"

                                4-11

BASIC09 Reference

340 DATA "is as sticky a50","can ooze like0",
"smells like0"
350 DATA "can be as tough to forget asp",~'~,
"can hurt 1 i k e0"
360 DATA "can be as cynical a50",
"makes a mockery of0"
370 DATA "drives me as crazy a50"
372 DATA "can bother me like0","blackens my hopes
like0"
374 DATA "can tickle me like0","can be as funny
a 50II

376 DATA "has the effect of0" 380 DATA "a sticky lollypop.","a web of intrigue." 390 DATA "castor oil.","a chocolate bath.","a broken toe." 400 DATA "honey and things.","personal defeat.","a wet diaper." 410 DATA "strange happenings.","a penniless purse." 420 DATA "a slimy snake.","a bad habit." 430 DATA "a bad memory chip.","a good fight.","a silly friend."

The Next Step

Even the best programmers make mistakes -a lot of them. BASIC09 provides a way to catch programming mistakes quickly and correct them. The next chapter tells you about BASIC09's powerful debugging functions.

4-12