Advertisement
Guest User

Untitled

a guest
May 17th, 2014
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.73 KB | None | 0 0
  1. TRS-80 Level II BASIC Reference Manual 1979
  2.  
  3. Chapter 9 / Editing
  4.  
  5. LEVEL II's editing features eliminate much of this extra work. In fact, it's so easy to alter program lines, you'll probably be able to do much more experimenting with multi-statement lines, complex expressions, etc.
  6. Commands, subcommands, and special function keys described in this chapter:
  7.  
  8. EDIT line number
  9.  
  10. This command puts you in the Edit Mode. You must specify which line you wish to edit, in one of two ways:
  11.  
  12. EDIT line-number [ENTER]
  13.  
  14. Lets you edit the specified line. If line number is not in use, or an FC error occurs
  15.  
  16. EDIT .
  17. Lets you edit the current program line - last line entered or altered or in which an error has occurred.
  18.  
  19. For example, type in and [ENTER] the following line:
  20.  
  21. 100 FOR I = 1 TO 10 STEP.5 : PRINT I, I^2, I^3 : NEXT
  22.  
  23. This line will be used in exercising all the Edit subcommands described below.
  24.  
  25. Now type EDIT 100 and hit [ENTER]. The Computer will display:
  26.  
  27. 100 _
  28.  
  29. You are now in the Edit Mode and may begin editing line 100.
  30.  
  31. NOTE: EDITing a program line automatically clears all variable values and eliminates pending FOR/NEXT and GOSUB operations.
  32. If BASIC encounters a syntax error during program execution, it will automatically put you in the EDIT mode.
  33. Before EDITing the line, you may want to examine current variable values. In this case, you must type Q as your first EDIT command.
  34. This will return you to the command mode, where you may examine variable values. Any other EDIT command (typing E, pressing ENTER, etc.) will clear out all variables.
  35.  
  36. ENTER key
  37.  
  38. Hitting [ENTER] while in the Edit Mode causes the Computer to record all the changes you've made (if any) in the current line, and returns you to the Command Mode.
  39.  
  40. nSpace-bar
  41. In the Edit Mode, hitting the Space-bar moves the cursor over one space to the right and displays any character stored in the preceding position. For example, using line 100 entered above, put the Computer in the Edit Mode so the Display shows:
  42.  
  43. 100 _
  44.  
  45. Now hit the Space-Bar. The cursor will move over one space, and the first character of the program line will be displayed. If this character was a blank, then a blank will be displayed. Hit the SpaceBar until you reach the first non-blank character:
  46.  
  47. 100 F_
  48.  
  49. is displayed. To move over more than one space at a time, hit the desired number of spaces first, and then hit the space-bar. For example, type 5 and hit Space-bar, and the display will show something like this (may vary depending on how many blanks you inserted in the line):
  50.  
  51. 100 FOR I=_
  52.  
  53. Now type 8 and hit the Space-bar. The cursor will move over 8 spaces to the right, and 8 more characters will be displayed.
  54.  
  55. n ← (Backspace)
  56.  
  57. Moves the cursor to the left by n spaces. If no number n is specified, the cursor moves back one space. When the cursor moves to the left, all characters in its "path" are erased from the display, but they are not deleted from the program line. Using this in conjunction with D or K or C can give misleading Video Displays of your program lines. So, be careful using it! For example, assuming you've used nSpace-Bar so that the Display shows:
  58.  
  59. 100 FOR I=1 TO 10_
  60.  
  61. type 8 and hit the ← key. The Display will show something like this:
  62.  
  63. 100 FOR I=_
  64. (will vary depending on number of blanks in your line 100)
  65.  
  66. SHIFT ↑
  67.  
  68. Hitting SHIFT and ↑ keys together effects an escape from any of the Insert subcommands listed below: X, I and H. After escaping from an Insert subcommand, you'll still be in the Edit Mode, and the cursor will remain in its current position. (Hitting [ENTER] is another way to exit these Insert subcommands).
  69.  
  70. L (List Line)
  71. When the Computer is in the Edit Mode, and is not currently executing one of the subcommands below, hitting L causes the remainder of the program line to be displayed. The cursor drops down to the next line of the Display, reprints the current line number, and moves to the first position of the line.
  72.  
  73. For example, when the Display shows
  74.  
  75. 100 _
  76.  
  77. hit L (without hitting [ENTER] key) and line 100 will be displayed:
  78.  
  79. 100 FOR I=1 TO 10 STEP .5 : PRINT I, I^2, I^3 : NEXT
  80. 100 _
  81.  
  82. This lets you look at the line in its current form while you're doing the editing.
  83.  
  84. X (Extend Line)
  85. Causes the rest of the current line to be displayed, moves cursor to end of line, and puts Computer in the Insert subcommand mode so you can add material to the end of the line. For example, using line 100, when the Display shows
  86.  
  87. 100 _
  88.  
  89. hit X (without hitting [ENTER]) and the entire line will be displayed; notice that the cursor now follows the last character on the line:
  90.  
  91. 100 FOR I=1 TO 10 STEP .5 : PRINT I, I^2, I^3 : NEXT_
  92.  
  93. We can now add another statement to the line, or delete material from the line by using the ← key. For example, type PRINT"DONE" at the end of the line. Now hit [ENTER]. If you now type LIST 100, the Display should show something like this:
  94.  
  95. 100 FOR I=1 TO 10 STEP .5 : PRINT 1, 1^2, 1^3 : NEXT : PRINT"DONE"
  96.  
  97. I (Insert)
  98. Allows you to insert material beginning at the current cursor position on the line. (Hitting ← will actually delete material from the line in this mode.) For example, type and [ENTER] the EDIT 100 command, then use the Space Bar to move over to the decimal point in line 100. The Display will show:
  99.  
  100. 100 FOR I=1 TO 10 STEP ._
  101.  
  102. Suppose you want to change the increment from .5 to .25. Hit the I key (don't hit [ENTER]) and the Computer will now let you insert material at the current position. Now hit 2 so the Display shows:
  103.  
  104. 100 FOR I=1 TO 10 STEP .2
  105.  
  106. You've made the necessary change, so hit SHIFT ↑ to escape from the Insert Subcommand. Now hit L key to display remainder of line and move cursor back to the beginning of the line:
  107. 100 FOR I=1 TO 10 STEP .25 : PRINT I, I^2, I^3 : NEXT : PRINT"DONE"
  108.  
  109. 100 _
  110.  
  111. You can also exit the Insert subcommand and save all changes by hitting [ENTER]. This will return you to Command mode.
  112.  
  113. A (Cancel and Restart)
  114.  
  115. Moves the cursor back to the beginning of the program line and cancels editing changes already made. For example, if you have added, deleted, or changed something in a line, and you wish to go back to the beginning of the line and cancel the changes already made: first hit SHIFT ↑ (to escape from any subcommand you may be executing); then hit A. (The cursor will drop down to the next line, display the line number and move to the first program character.
  116.  
  117. E (Save Changes and Exit)
  118.  
  119. Causes Computer to end editing and save all changes made. You must be in Edit Mode, not executing any subcommand, when you hit E to end editing.
  120.  
  121. Q (Cancel and Exit)
  122.  
  123. Tells Computer to end editing and cancel all changes made in the current editing session. If you've decided not to change the line, type Q to cancel changes and leave Edit Mode.
  124.  
  125. H (Hack and Insert)
  126.  
  127. Tells Computer to delete remainder of line and lets you insert material at the current cursor position. Hitting ← will actually delete a character from the line in this mode. For example, using line 100 listed above, enter the Edit Mode and space over to the last statement, PRINT"DONE". Suppose you wish to delete this statement and insert an END statement. Display will show:
  128.  
  129. 100 FOR I=1 TO 10 STEP .25 : PRINT I, I^2, I^3 : NEXT :_
  130.  
  131. Now type H and then type END. Hit [ENTER] key. List the line:
  132.  
  133. 100 FOR I=1 TO 10 STEP .25 : PRINT I, I^2, I^3 : NEXT : END
  134.  
  135. should be displayed.
  136.  
  137. nD (Delete)
  138.  
  139. Tells Computer to delete the specified number n characters to the right of the cursor. The deleted characters will be enclosed in exclamation marks to show you which characters were affected. For example, using line 100, space over to the PRINT command statement:
  140.  
  141. 100 FOR I=1 TO 10 STEP .25 :_
  142.  
  143. Now type 19D. This tells the Computer to delete 19 characters to the right of the cursor. The display should show something like this:
  144.  
  145. 100 FOR I=1 TO 10 STEP .25 : !PRINT I, I^2, I^3 :!_
  146.  
  147. When you list the complete line, you'll see that the PRINT statement has been deleted.
  148.  
  149. nC (Change)
  150.  
  151. Tells the Computer to let you change the specified number of characters beginning at the current cursor position. If you type C without a preceding number, the Computer assumes you want to change one character. When you have entered n number of characters, the Computer returns you to the Edit Mode (so you're not in the nC Subcommand). For example, using line 100, suppose you want to change the final value of the FOR-NEXT loop, from " 10" to " 15". In the Edit Mode, space over to just before the "0" in "10".
  152.  
  153. 100 FOR I=1 TO 1_
  154.  
  155. Now type C. Computer will assume you want to change just one character.
  156. Type 5, then hit L. When you list the line, you'll see that the change has been made.
  157.  
  158. 100 FOR I=1 TO 15 STEP .25 : NEXT : END
  159. would be the current line if you've followed the editing sequence in this chapter.
  160.  
  161. The ← does not work as a backspace under the C command in Edit mode.
  162. Instead, it replaces the character you want to change with a backspace. So it should not be used. If you make a mistake while typing in a change, Edit the line again to correct it, instead of using ← .
  163.  
  164. nSc (Search)
  165. Tells the Computer to search for the nth occurrence of the character c, and move the cursor to that position. If you don't specify a value for n, the Computer will search for the first occurrence of the specified character. If character c is not found, cursor goes to the end of the line. Note: The Computer only searches through characters to the right of the cursor.
  166. For example, using the current form of line 100, type EDIT 100 ( [ENTER] ) and then hit 2S: . This tells the Computer to search for the second occurrence of the colon character. Display should show:
  167.  
  168. 100 FOR I=1 TO 15 STEP.25 : NEXT _
  169.  
  170. You may now execute one of the subcommands beginning at the current cursor position. For example, suppose you want to add the counter variable after the NEXT statement. Type I to enter the Insert subcommand, then type the variable name, I. That's all you want to insert, so hit SHIFT ↑ to escape from the Insert subcommand. The next time you list the line, it should appear as:
  171.  
  172. 100 FOR I=1 TO 15 STEP.25 : NEXT I : END
  173.  
  174. nKc (Search and "Kill")
  175.  
  176. Tells the Computer to delete ail characters up to the nth occurrence of character c, and move the cursor to that position. For example, using the current version of line 100, suppose we want to delete the entire line up to the END statement. Type EDIT 100 ( [ENTER] ), and then type 2K: . This tells the Computer to delete all characters up to the 2nd occurrence of the colon. Display should show:
  177.  
  178. 100 !FOR I=1 TO 15 STEP .25 : NEXT I!_
  179.  
  180. The second colon still needs to be deleted, so type D . The Display will now show:
  181.  
  182. 100 !FOR I=1 TO 15 STEP .25 : NEXT I!!:!_
  183.  
  184. Now hit [ENTER] and type LIST 100 ( [ENTER] ).
  185. Line 100 should look something like this:
  186.  
  187. 100 END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement