TL01.TXT 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  1. TURBO-LESSONS - A Pascal Tutorial Version 1.01 Page 1
  2. TURBO-LESSONS
  3. A TURBO Pascal Tutorial
  4. Version 1.01
  5. by Lyle M. Faurot
  6. June 8, 1985
  7. Copyright (C), 1985 by Lyle Faurot. All rights reserved.
  8. TURBO is a trademark of Borland International.
  9. Œ
  10. TURBO-LESSONS - A Pascal Tutorial Version 1.01 Page 2
  11. T A B L E O F C O N T E N T S
  12. Page
  13. Introduction . . . . . . . . . . . . . . . . . . . . . . . 4
  14. Distribution Notice . . . . . . . . . . . . . . . . . . . 5
  15. TURBO-LESSON 1: GETTING STARTED
  16. Loading TURBO . . . . . . . . . . . . . . . . . . . . 5
  17. Main Menu . . . . . . . . . . . . . . . . . . . . . . 5
  18. TURBO-LESSON 2: EDITING PROGRAMS
  19. Starting an edit session . . . . . . . . . . . . . . 10
  20. Ending an edit session . . . . . . . . . . . . . . . 11
  21. Moving the cursor . . . . . . . . . . . . . . . . . . PROG2
  22. Inserting/Replacing text . . . . . . . . . . . . . . PROG2
  23. Deleting text . . . . . . . . . . . . . . . . . . . . PROG2
  24. Auto-tabbing . . . . . . . . . . . . . . . . . . . . PROG2
  25. TURBO-LESSON 3: PROGRAM STRUCTURE
  26. Program structure . . . . . . . . . . . . . . . . . . 12
  27. Compiler Directive, $U+ . . . . . . . . . . . . . . . 13
  28. WRITE and WRITELN statements . . . . . . . . . . . . 13
  29. Comments . . . . . . . . . . . . . . . . . . . . . . 14
  30. TURBO-LESSON 4: DECLARATIONS, INPUT
  31. DECLARATIONS part of program . . . . . . . . . . . . 16
  32. VAR declaration . . . . . . . . . . . . . . . . . . . 16
  33. Input usint READLN statement . . . . . . . . . . . . 17
  34. Integer Variables . . . . . . . . . . . . . . . . . . 18
  35. TURBO-LESSON 5: INTEGER EXPRESSIONS
  36. Assignment statements . . . . . . . . . . . . . . . . 20
  37. Integer expressions . . . . . . . . . . . . . . . . . 21
  38. Problems with expressions . . . . . . . . . . . . . . 23
  39. TURBO-LESSON 6: CONDITIONAL PROCESSING
  40. Selection structures . . . . . . . . . . . . . . . . 25
  41. IF statement (One-way selection) . . . . . . . . . . 26
  42. IF statement (Two-way selection) . . . . . . . . . . 27
  43. TURBO-LESSON 7: REPEAT STATEMENT
  44. CHARacter variables . . . . . . . . . . . . . . . . . 28
  45. BOOLEAN variables . . . . . . . . . . . . . . . . . . 29
  46. REPEAT statement . . . . . . . . . . . . . . . . . . 30
  47. TURBO-LESSON 8: CASE STATEMENT
  48. Block statements . . . . . . . . . . . . . . . . . . 32
  49. CASE statement . . . . . . . . . . . . . . . . . . . 34
  50. TURBO-LESSON 9: FOR STATEMENT
  51. Print field width indicator, ":n" . . . . . . . . . . 36
  52. FOR statement . . . . . . . . . . . . . . . . . . . . 37
  53. TURBO-LESSON 10: WHILE STATEMENT
  54. CONSTant declaration . . . . . . . . . . . . . . . . 38
  55. WHILE statement . . . . . . . . . . . . . . . . . . . 39
  56. Delay timing loop . . . . . . . . . . . . . . . . . . 41
  57. Œ
  58. TURBO-LESSONS - A Pascal Tutorial Version 1.01 Page 3
  59. INTRODUCTION TO TURBO-LESSONS
  60. When Borland International ran their first ads for TURBO
  61. PASCAL my reaction was "You gotta be kidding - they can't do
  62. that". But, it seems they did! I've been enjoying this
  63. programming system ever since. Apparently a great many other
  64. programmers are either programming in TURBO or would like to
  65. learn how. TURBO-LESSONS were designed to meet that need.
  66. Each TURBO-LESSON is a bite-size tutorial which introduces
  67. one or more new concepts. Each of the lessons are presented in
  68. the same format which includes the OBJECTIVES of the lesson, and
  69. the TUTORIAL portion of the lesson. Most lessons direct you to
  70. work with a sample program which is provided with these lessons.
  71. Be sure you make a back-up copy of the programs - you will
  72. be modifying and adding to the sample programs, and may want to
  73. return to the original copy of a program.
  74. Sample programs are numbered to correspond to the lessons:
  75. PROG1 goes with TURBO-LESSON 1, PROG2, PROG2A go with TURBO-
  76. LESSON2, . . .
  77. To begin, you should print the TURBO-LESSONS before loading
  78. TURBO. To help you get started, TURBO-LESSON 1 shows you how to
  79. load TURBO and run a sample program.
  80. ****************************************
  81. D I S T R I B U T I O N N O T I C E
  82. ****************************************
  83. TURBO-LESSONS are being distributed as USER-SUPPORTED software.
  84. Suggested donation, $7.00, for this first set, lessons 1-10, may
  85. be sent to:
  86. Dr. Lyle Faurot
  87. 1904 18th Ave. South
  88. Moorhead, MN 56560
  89. COPYING BY ORGANIZATIONS
  90. Clubs and other non-profit organizations may copy these lessons
  91. for their members, with the following conditions:
  92. 1. No charge is made for TURBO-LESSONS, except a distribution
  93. charge may be made to cover the price of the diskette. Suggested
  94. donation is to be made directly to the author of the lessons.
  95. 2. Club members are informed that TURBO-LESSONS are distributed
  96. as user-supported software.
  97. 3. TURBO-LESSONS are distributed unmodified.
  98. Œ
  99. TURBO-LESSONS - A Pascal Tutorial Version 1.01 Page 4
  100. TURBO-LESSON 1: GETTING STARTED
  101. OBJECTIVES - In this lesson you will learn about:
  102. 1. Loading TURBO
  103. 2. Using the Main Menu to Load, Compile, and Run a program
  104. INTRODUCTION
  105. TURBO-LESSONS were written with the following goals in mind:
  106. -- Present the concepts of Pascal and the TURBO Pascal
  107. implementation in bite-size chunks (called lessons).
  108. -- Provide one or more sample Pascal programs with each
  109. lesson. Programming examples are often more helpful
  110. than eloquent discussion in learning to program.
  111. -- Structure the lessons in a parallel format to make them
  112. more useful later as a reference. The OBJECTIVE section
  113. at the beginning of each lesson will help you locate
  114. a topic later.
  115. -- Structure the lessons in an Action format. If you are
  116. like me, you probably learn programming best by doing.
  117. -- Mark the points where some action is suggested. This
  118. should allow for differences in learning styles. The
  119. action points are marked as follows:
  120. ##### DO:
  121. For those who like to hit the high points as fast as
  122. possible, these action markers will point the way.
  123. Now, without further delay, on with the show!
  124. Œ
  125. TURBO-LESSONS - A Pascal Tutorial Version 1.01 Page 5
  126. 1. Loading TURBO.
  127. To get started, put a diskette with TURBO PASCAL in your default
  128. drive.
  129. ##### DO:
  130. Type TURBO and enter.
  131. A message will appear:
  132. Include error messages (Y/N)?
  133. You should answer Y to provide on-screen error messages. The
  134. Main Menu will appear at this point.
  135. 2. Using the Main Menu to Load, Compile, and Run a program.
  136. The menu should appear with one letter of each option
  137. highlighted.
  138. ##### DO:
  139. Adjust the brightness level of your screen. You may need to
  140. adjust both brightness and contrast to make the key letters stand
  141. out at a comfortable level.
  142. The main menu is the starting point for most of the things you
  143. will do with TURBO. Some of the options will be discussed in
  144. more detail later, but for now, you should learn to get back to
  145. the main menu from each of the options.
  146. ******************** Logged drive:
  147. The Logged drive is where your Work files are stored. This
  148. option is used to change your logged drive.
  149. ##### DO:
  150. Type L.
  151. Computer responds: "New drive:"
  152. Type B (or another drive) and enter.
  153. Look at the top of the screen. Did the logged drive change?
  154. Now, depress the space bar. It appeared that no change had been
  155. made until the menu screen was redisplayed.
  156. Œ
  157. TURBO-LESSONS - A Pascal Tutorial Version 1.01 Page 6
  158. ******* NOTE: SOME OF THE OPTIONS DO NOT UPDATE THE MENU SCREEN.
  159. YOU CAN REDISPLAY THE MENU WITH THE SPACE BAR OR ENTER KEY.
  160. You could have responded to the "New drive:" message by
  161. depressing the enter key without entering another drive
  162. designator. The enter key by itself is used to escape from this
  163. option without making any changes.
  164. The first four options at the top of the menu, L, A, W, and M all
  165. use the enter key alone as an escape key.
  166. ******************** Active directory: \
  167. Use the A option to change the Active subdirectory if your logged
  168. drive is a hard disk.
  169. ##### DO:
  170. Type A.
  171. Computer responds: "New directory:"
  172. Type subdirectory name and enter or just enter for no change.
  173. ******************** Work file:
  174. This is where you name your work file. The work file will hold
  175. the PASCAL program you are writing or editing.
  176. ##### DO:
  177. Type W.
  178. Computer responds: "Work file name:"
  179. Type PROG1 and enter. (If you get the message, "New File",
  180. PROG1.PAS was not found on your logged drive. Your sample
  181. programs, including PROG1, should be on the logged drive).
  182. ******************** Main file:
  183. Ignore this option for now. If you just can't resist typing M at
  184. this point, remember that Enter is the escape key for this
  185. option.
  186. Œ
  187. TURBO-LESSONS - A Pascal Tutorial Version 1.01 Page 7
  188. ******************** Run
  189. This option is used to execute a program, compiling it first, if
  190. necessary.
  191. ##### DO:
  192. Type R.
  193. The program in your work file, PROG1, is compiled and executed.
  194. Type R again.
  195. Note that the program runs again without compiling. The Run
  196. option will only compile if changes have been made in the program
  197. since the previous compile.
  198. Depress the space bar to get the menu back.
  199. ******************** Compile
  200. The program may be compiled without executing by using the C
  201. option. You may want to compile to see an error message without
  202. running the program. Or you may be compiling a COM file, which
  203. cannot be executed until you exit TURBO to DOS.
  204. ##### DO:
  205. Type C.
  206. The program compiles but doesn't run. Use this option when you
  207. want to compile without executing the program immediately.
  208. ******************** Edit
  209. The editor is used to enter a new program or change a program.
  210. Another lesson is devoted to editing. For now, you should find
  211. out how to get back to the menu from this option.
  212. ##### DO:
  213. Type E.
  214. The program, PROG1, appears on the screen, ready to edit.
  215. Use the Ctrl-K, Ctrl-D sequence to return to the main menu.
  216. Œ
  217. TURBO-LESSONS - A Pascal Tutorial Version 1.01 Page 8
  218. ##### DO:
  219. Type Ctrl-K, Ctrl-D. (While depressing the Ctrl key, type K
  220. followed by D.)
  221. The main menu reappears. Note that there is no way to abandon
  222. the edited file in memory. This is not so bad since the edited
  223. copy of the program in memory is not automatically saved to disk.
  224. You can use the Work file option to get another copy of the
  225. program from disk.
  226. ******************** Save
  227. Use this option to copy your current work file from memory to
  228. disk.
  229. ##### DO:
  230. Type S.
  231. The program, PROG1, is saved to the disk on the drive designated
  232. when you named this work file. Since the work file is not
  233. automatically saved to disk, TURBO reminds you to save the file
  234. before any option which would destroy the copy of the file in
  235. memory.
  236. NOTE: REMEMBER, IT IS UP TO YOU TO SAVE YOUR WORK FILE. IT'S A
  237. GOOD IDEA TO SAVE IT FREQUENTLY, IN CASE SOMETHING SUCH AS AN
  238. INFINITE LOOP FORCES YOU TO RE-BOOT (IN WHICH CASE YOUR WORK FILE
  239. IN MEMORY WOULD BE FOREVER GONE!)
  240. ******************** Dir
  241. The D option works similar to DIR in DOS.
  242. ##### DO:
  243. Type D.
  244. Computer responds: "Dir mask:"
  245. Depress the Enter key to get a directory of the logged drive or
  246. use drive designator to get a directory of another drive. You
  247. can use the wildcards, "*" and "?".
  248. Œ
  249. TURBO-LESSONS - A Pascal Tutorial Version 1.01 Page 9
  250. ******************** compiler Options
  251. These will be discussed later when they are needed. Try the O
  252. option now to be sure you know how to get back to the menu.
  253. ##### DO:
  254. Type O.
  255. The compiler Options menu is displayed.
  256. You can choose the various compiler options by typing the
  257. corresponding letter.
  258. ##### DO:
  259. Type C.
  260. Notice the arrow moved to a different option.
  261. Type H.
  262. Type M.
  263. Be sure to leave the compiler option set to M, memory before
  264. returning to the main menu.
  265. Type Q.
  266. The main menu reappears.
  267. ******************** Quit
  268. This option returns you to DOS. When you are through
  269. experimenting with the menu options,
  270. ##### DO:
  271. Type Q.
  272. You will be prompted to save your work file if it has been
  273. modified since you last saved it. The prompt of the default
  274. drive will be displayed.
  275. Œ