PROG2.PAS 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. PROGRAM PROG2;
  2. { Copyright (C), 1985 by Lyle Faurot. All rights reserved.
  3. Note that this program is not a program to compile and run,
  4. but a tutorial on editing programs.
  5. PROG2 is part of TURBO-LESSON 2.
  6. OBJECTIVE 3. Move the cursor to desired location.
  7. (See TURBO-LESSON 2 for list of objectives).
  8. One of the basics of any screen editor or word processor is the
  9. ability to move around the screen easily. The arrow keys at the
  10. right of the keyboard are used to move the cursor. Note that
  11. the following may be substituted for the arrow keys:
  12. ctrl-s = left-arrow
  13. ctrl-d = right-arrow
  14. ctrl-e = up-arrow
  15. ctrl-x = down-arrow
  16. ##### DO:
  17. Try out the cursor movement keys by moving the cursor to the
  18. numbers below in order starting at 1:
  19. 1
  20. 4
  21. 3
  22. 5
  23. 2 6
  24. ##### DO:
  25. Move the cursor around while watching the top line of this
  26. screen. The line and column are always indicated there
  27. if you need this information.
  28. Notice that the screen can be "pushed" up or down by holding
  29. down the up-arrow or down-arrow.
  30. ##### DO:
  31. Try out this feature by scrolling to the beginning of this
  32. program, using the up-arrow, and then scrolling back here using
  33. the down-arrow.
  34. Was that a little slow? There are some faster ways to move the
  35. cursor if you are moving it more than a few spaces or lines.
  36. Instead of using the up-arrow to scroll to the beginning of this
  37. file, you could have used ctrl-PgUp.
  38. ##### DO:
  39. Try ctrl-PgUp then return here using the down arrow. To get to
  40. the end of the file, use ctrl-PgDn. Before you try that, you
  41. should know that PgUp and PgDn without the control key will move
  42. the cursor up or down one screen at a time.
  43. ##### DO:
  44. Try crtl-PgDn to move the cursor to the end of this file and
  45. return here using ctrl-PgUp.
  46. Another useful combination is ctrl-left-arrow and ctrl-right-arrow.
  47. By using the control key with the left and right arrow keys you can
  48. move left or right one word at a time.
  49. ##### DO:
  50. Use ctrl-left-arrow and ctrl-right-arrow to move the cursor back
  51. and forth one word at a time on these two lines.
  52. Also try crtl-up-arrow. What happened? Only the left and right
  53. arrow keys are combined with the control key for cursor control.
  54. The Home and End keys are also used for cursor control.
  55. ##### DO:
  56. Try the Home and End keys.
  57. What happens? This gives you a quick way to get to the beginning
  58. or end of a line. You will find the End key especially useful in
  59. writing programs.
  60. What cursor movement results when you combine the control key
  61. with Home and End. Try it!
  62. ##### DO:
  63. Experiment with ctrl-Home and ctrl-End.
  64. This provides a quick route to the top or bottom of the current
  65. screen.
  66. LEARNING THESE CURSOR MOVEMENT KEYS AND KEY COMBINATIONS NOW
  67. WILL SAVE TIME AND FRUSTRATION LATER WHEN YOU ARE WORKING
  68. ON PROGRAMS! YOU MAY WANT TO POST THE FOLLOWING LIST BY YOUR
  69. COMPUTER UNTIL YOU BECOME COMFORTABLE WITH EDITING.
  70. Left-arrow Left one character
  71. Right-arrow Right one character
  72. Ctrl-Left-arrow Left one word
  73. Ctrl-Right-arrow Right one word
  74. Home Left end of current line
  75. End Right end of current line
  76. Ctrl-Home Top of current screen
  77. Ctrl-End Bottom of current screen
  78. PgUp Previous screen
  79. PgDn Next screen
  80. Ctrl-PgUp Beginning of file
  81. Ctrl-PgDn End of file
  82. (Program PROG2A will print this table.)
  83. OBJECTIVE 4. Insert/replace text.
  84. There are two ways to type text when using an editor or word
  85. processor:
  86. (1) Insert new text while pushing existing text to the right to
  87. make room for the new text, and
  88. (2) Replace text by typing over the original text.
  89. ##### DO:
  90. Look at the top line of this screen while depressing the Ins
  91. key several times. The status line indicates "Insert" or
  92. "Overwrite" mode is presently active. The Ins key gives you
  93. a way to switch modes.
  94. ##### DO:
  95. Try the two typing modes on the practice text below:
  96. *************************************************************
  97. PRACTICE TEXT: DON'T WORRY ABOUT MAKING A MISTAKE --
  98. THIS TEXT IS HERE FOR YOUR EXPERIMENTATION. Use the better
  99. of the two modes to correct mistakes, insert some new text
  100. (how about a nice, overworked term like "user-friendly"),
  101. and change some of the upper case text to lower case.
  102. There ar sume mistekes hear for you to coreect.
  103. Use the Insert mode with the right arrow and the space bar
  104. to correct the following:
  105. Thequickbrownfoxjumpedoverthelazydog'sback.
  106. *************************************************************
  107. OBJECTIVE 5. Delete text.
  108. There are several ways to delete text:
  109. (1) Use the Del key or ctrl-G to delete the character at the
  110. cursor position and pull the characters from the right. You
  111. might think of this as "eating" the characters to the right.
  112. ##### DO:
  113. Use the Del key and Ctrl-G to eliminate the x's below:
  114. abcdexxxfghijkxxxxxxxxlmxnopxxxqrstxxxxxxxxxxxxxxxuvwxyz.
  115. (2) Use the backspace key to delete the character to the left
  116. of the cursor and pull the characters from the right. This
  117. "eats" characters to the left.
  118. ##### DO:
  119. Use the backspace to eliminate the letters from f to k in the
  120. practice line above.
  121. NOTE THAT Del, ctrl-G, and backspace WORK THE SAME WAY IN
  122. EITHER INSERT OR OVERWRITE MODE.
  123. (3) Use the space bar to space out characters in the OVERWRITE
  124. mode. You shouldn't need this very often if you learn to use
  125. the other methods for deleting text.
  126. (4) Use ctrl-Y to delete the entire line.
  127. ##### DO:
  128. Delete the blank line and the extra Line2 below using ctrl-Y:
  129. Line 1
  130. Line 2
  131. Line 2
  132. Line 3
  133. Line 4
  134. Line 5
  135. OBJECTIVE 6. Auto-tab for readable programs.
  136. PASCAL provides very good tools for structuring programs.
  137. The advantages gained from carefully structuring a program will
  138. be wasted if the program itself is not typed in a manner which
  139. makes the structure clear. Tabbing in this editor is a little
  140. different - depressing the tab key advances the cursor to a
  141. position under the next word in the previous line! That may
  142. seem a little strange, but don't make up your mind until you
  143. try the both exercises in this section.
  144. On a typewriter the tabs are fixed. Each time you depress the
  145. TAB key you move so many spaces. TURBO sets the tabs by looking
  146. at the line immediately above the cursor. The first letter in
  147. each word is the position of your tab for the line below.
  148. For example, this line sets tabs in the positions numbered below:
  149. 1 2 3 4 5 6 7 8 9 10 11
  150. When I type in a different line, the tabs change--like this
  151. 1 2 3 4 5 6 7 8 9 10 11
  152. This makes it easy to line up program commands with tabs:
  153. No indent on this line. Typing return and TAB after here
  154. Produces first indent under the "i." Typing return here
  155. Continues under the letter "P." Typing return then TAB here
  156. Indents under the letter "u." Return after here
  157. Lines up under "I." Return again after here
  158. Does the same!
  159. In the sample program below, the first line is entered manually,
  160. resulting in tabs at characters "i" ":" "I" on the first line.
  161. ##### DO:
  162. Try the tab feature by typing in the following program segment:
  163. VAR i,j,k : Integer;
  164. a,b,c,d : Real;
  165. First_Name : String[10];
  166. Last_Name : String[16];
  167. Zip : String[5];
  168. (With the Insert mode on, the program segment may be typed in
  169. below without overwriting the text that follows.)
  170. A feature based on this tabbing technique is used to provide
  171. "structured" indentation of statement lines.
  172. ##### DO:
  173. Watch the line at the top of the screen as you depress ctrl-Q
  174. followed by ctrl-I several times.
  175. The word, Indent, should toggle on and off. When Indent appears
  176. in the status line, the automatic indentation feature is active.
  177. When the enter key is depressed, the cursor will return to a
  178. position under the leftmost word of the previous line if the
  179. Indent feature is active. Otherwise, the cursor returns to the
  180. left margin.
  181. Remember ctrl-Q, ctrl-I will toggle this feature off (and back
  182. on) in case it gets in your way at times.
  183. ##### DO:
  184. Try typing in the following statements with the Indent feature
  185. on to see how it works:
  186. BEGIN
  187. REPEAT
  188. i := i + k;
  189. c := a + b;
  190. REPEAT
  191. ReadLn(First_Name);
  192. ReadLn(Last_Name);
  193. WriteLn(First_Name, ' ',Last_Name);
  194. UNTIL Last_Name = 'ZZZ';
  195. WriteLn('All names printed');
  196. UNTIL i > 20;
  197. END.
  198. ********** End of PROG2 tutorial ******************
  199. }
  200.