home *** CD-ROM | disk | FTP | other *** search
/ The Programmer Disk / The Programmer Disk (Microforum).iso / xpro / tutor / pro29 / print.me < prev    next >
Encoding:
Text File  |  1992-03-10  |  86.6 KB  |  2,236 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.                               Welcome  to
  21.                             A D A - T U T R
  22.                        The Interactive Ada Tutor
  23.                         by John J. Herro, Ph.D.
  24.                     Software Innovations Technology
  25.  
  26.                   These are the printed course notes.
  27.  
  28.                         Ver. 2.01, 10 Mar. 1992
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.                    Copyright 1988-1992 John J. Herro
  46.  
  47.                     Software Innovations Technology
  48.              1083 Mandarin Dr. NE, Palm Bay, FL 32905-4706
  49.                              (407)951-0233
  50.  
  51.  
  52.                   You may make copies of these notes,
  53.                   in printed or machine-readable form.
  54.  
  55.                 You may also copy the computer program.
  56.                      Please see page 1 for details.
  57.  
  58.  
  59.                                                                Page  i
  60.  
  61.                           TABLE OF CONTENTS
  62.  
  63.  
  64. Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   i
  65. Acknowledgments  . . . . . . . . . . . . . . . . . . . . . . . . .  ii
  66. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . .   1
  67. Registration and Licenses - What is Shareware? . . . . . . . . . .   2
  68. Special Offer to Companies, Schools, Etc.  . . . . . . . . . . . .   3
  69. Note to Compiler Companies . . . . . . . . . . . . . . . . . . . .   5
  70. Does Your Screen Show Strange Characters Like Arrows and Brackets?   6
  71. The Ada Reserved Words . . . . . . . . . . . . . . . . . . . . . .   7
  72. Steps for Outside Assignment 1, Preparing to Run Ada . . . . . . .   8
  73. Listings of HELLO.ADA and ADD.ADA  . . . . . . . . . . . . . . . .   9
  74. Listing of TRITEST.ADA . . . . . . . . . . . . . . . . . . . . . .  10
  75. Steps for Outside Assignment 2, Exercise in Enumeration Types  . .  12
  76. Listing of NEXTDATE.ADA  . . . . . . . . . . . . . . . . . . . . .  13
  77. Steps for Outside Assignment 3, Exercise in Records  . . . . . . .  14
  78. Listing of FIBTEST.ADA . . . . . . . . . . . . . . . . . . . . . .  15
  79. Steps for Outside Assignment 4, Exercise in Recursion  . . . . . .  16
  80. Simplified Specification for TEXT_IO . . . . . . . . . . . . . . .  17
  81. Listings of Procedure FILECOPY and Function EXISTS . . . . . . . .  19
  82. Requirements for the Program LEDIT . . . . . . . . . . . . . . . .  20
  83. Steps for Outside Assignment 5, Writing a Simple Line Editor . . .  25
  84. How to Test LEDIT  . . . . . . . . . . . . . . . . . . . . . . . .  26
  85. Listing of LEDIT.ANS . . . . . . . . . . . . . . . . . . . . . . .  29
  86. Listing of TASKING.DUM . . . . . . . . . . . . . . . . . . . . . .  33
  87. Steps for Outside Assignment 6, Exercise in Tasking  . . . . . . .  34
  88. Output from TASKING.EXE After Modification of TASKING.ADA  . . . .  35
  89. Listing of TASKING.ANS . . . . . . . . . . . . . . . . . . . . . .  36
  90.  
  91. Appendix A:  Would You Like a Textbook to Use Along with ADA-TUTR?  37
  92. Appendix B:  Running BOOK to Print All the Screens . . . . . . . .  38
  93. Appendix C:  Some Ada Compilers Available for the PC . . . . . . .  39
  94. Appendix D:  Sample Multi-User Software License  . . . . . . . . .  40
  95. Appendix E:  Do You Need a Screen Editor / Word Processor? . . . .  42
  96. Appendix F:  Installing ADA-TUTR on Other Computers  . . . . . . .  43
  97. Appendix G:  We Listen!  New Features of ADA-TUTR  . . . . . . . .  48
  98. Appendix H:  Disclaimer of Warranty  . . . . . . . . . . . . . . .  50
  99.  
  100.                                                                Page ii
  101.  
  102.                            ACKNOWLEDGMENTS
  103.  
  104. The following trademarks are used in these notes and in the
  105. accompanying files:
  106.  
  107.         FirstAda         Alsys, Inc.
  108.         IBM              International Business Machines Corp.
  109.         IntegrAda        Aetech, Inc.
  110.         Janus/Ada        R R Software, Inc.
  111.         Meridian Ada     Meridian Software Systems, Inc.
  112.         Open Ada         Meridian Software Systems, Inc.
  113.         PC-Write         Quicksoft
  114.         TeleGen          Telesoft Corporation
  115.         Turbo Pascal     Borland International
  116.         UNIX             AT & T
  117.         VAX              Digital Equipment Corporation
  118.         VMS              Digital Equipment Corporation
  119.  
  120. The file ONECHAR.C was sent to us by Mr. David Hill, 7549 Wynford
  121. Street, Salt Lake City, UT 84121, and the file ALTCHAR.C was sent to
  122. us by Mr. Richard Conn, 2700 Bowline Court, Maineville, OH 45039.
  123. We're very grateful to Mr. Hill and to Mr. Conn for giving us
  124. permission to include these files in ADA-TUTR.  When used with
  125. UNIX.ADA, these files provide two ways to run the Tutor on UNIX based
  126. machines without having to strike ENTER after each response.  See
  127. pages 43-47.
  128.  
  129. The programs in this version of ADA-TUTR were compiled with the
  130. Meridian Ada Compiler, v4.1, and optimized with the Meridian IFORM
  131. Optimizer, v1.0.  The .EXE files contain Meridian's runtime, and were
  132. further compressed with the public domain program LZEXE, v0.91, by
  133. Fabrice Bellard of Grabels, France.
  134.  
  135.                                                                Page  1
  136.  
  137.                              INTRODUCTION
  138.  
  139. ADA-TUTR, the Interactive Ada Tutor, will make you an excellent Ada
  140. programmer in minimum time.  You'll learn good Ada program design
  141. techniques, not just Ada syntax.  ADA-TUTR runs on PCs as well as
  142. workstations and mainframes.  On PCs an Ada compiler is helpful, but
  143. not required.  The PC can have a monochrome or a color monitor.
  144.  
  145. These printed notes aren't meant to be a complete course, or even a
  146. summary, of Ada.  They merely accompany the program ADA-TUTR, which is
  147. a complete course.  You can't "study" these printed notes alone.  For
  148. now, just read pages 1, 2, and 6.
  149.  
  150. ADA-TUTR lets you learn at your own pace.  So that you don't feel
  151. pressured, ADA-TUTR doesn't keep track of the number of right and
  152. wrong answers.  It simply tells you whether your answers are correct,
  153. and why.  Also, there's no time limit for answering the questions or
  154. completing the Outside Assignments.
  155.  
  156. Because I want every programmer to have a chance to learn the best
  157. programming language, I made ADA-TUTR available very inexpensively as
  158. Shareware.  Shareware isn't the same as public domain, and ADA-TUTR
  159. isn't free.  But you may TRY it for free, and register or buy a
  160. license only if you use it.  Please see pages 2-3 for details.
  161.  
  162. Whether or not you use ADA-TUTR and register (or buy a license),
  163. you're encouraged to make unmodified copies of the program and
  164. distribute them.  Please put ADA-TUTR on computer bulletin boards,
  165. distribute copies at club meetings, give them to companies, etc.  You
  166. may charge a small fee to copy the program, provided you make it clear
  167. that the fee is only for the copy, and doesn't pay for the Shareware.
  168. (Companies that copy Shareware usually charge about $2 to $10 per
  169. diskette.)  Bulletin boards may carry ADA-TUTR even if they charge for
  170. access.  Please contact us for permission to include ADA-TUTR with
  171. commercial products, such as Ada compilers (see page 5).  You may use
  172. file compression, library, and archive programs on ADA-TUTR; we won't
  173. interpret that as "modifying" the program.  You may also add your own
  174. files.  (The files included with ADA-TUTR are briefly described in
  175. ED.DIR.)  If you register, you can earn substantial money distributing
  176. ADA-TUTR; please see page 2 for details.
  177.  
  178. Ada will become more and more important, since the Department of
  179. Defense mandated its use in mission-critical systems, and is now
  180. making it very hard to obtain waivers.  Although learning Ada takes
  181. real effort, you'll be able to write software that's more reliable
  182. and easier to modify a month or a year later.
  183.  
  184. New features of this version of ADA-TUTR are described on pages 48-49.
  185. Please send me your comments and suggestions.  I wish you success
  186. using ADA-TUTR!
  187.  
  188. John J. Herro, Ph.D., Software Innovations Technology
  189. 1083 Mandarin Drive NE, Palm Bay, FL 32905-4706   (407)951-0233
  190.  
  191.                                                                Page  2
  192.  
  193.             REGISTRATION AND LICENSES - WHAT IS SHAREWARE?
  194.  
  195. Shareware is a way of marketing a program.  It lets you try the
  196. program before spending money for it.  If you decide to use the
  197. program, you send a small payment to register your copy or buy a
  198. license.  We give you several incentives to do so, explained below.
  199. You're on your honor; you know whether you're "using" ADA-TUTR or
  200. only "trying" it.
  201.  
  202. To use ADA-TUTR, individuals register as described below.  Companies,
  203. schools, and other organizations can register each individual who
  204. uses the program, or buy a Multi-User License as described on the next
  205. page.
  206.  
  207.  
  208. INDIVIDUALS:  Register your copy for only $25.  When you register,
  209. please give us the serial number from the ADA-TUTR opening screen.
  210. We'll assign you a new serial number.  Then run CHANGESN to put your
  211. new number into the program, and give copies to individuals, schools,
  212. companies, clubs, computer bulletin boards, etc.
  213.  
  214. We'll send you a commission of $5 for each individual who registers
  215. from one of your copies, and TEN PERCENT for each Multi-User License
  216. sold from one of your copies!  As you can see from the next page, you
  217. can earn up to $240 per license sold!  Commissions are paid quarterly.
  218. If you like, print the file AD.TXT and use copies as an advertisement.
  219.  
  220. Registration includes the right to use ADA-TUTR as long as you like,
  221. and it includes technical support for one year.  While you have
  222. technical support, we'll inform you of any important updates to
  223. ADA-TUTR, and send you updated copies for only $5 each ($10 if you
  224. prefer a 3.5" diskette, free if you send us a blank, formatted,
  225. diskette with a stamped, addressed diskette mailer).  We're planning a
  226. major update of ADA-TUTR with the next revision (9X) of the Ada
  227. language.  You can renew technical support for only $10 a year.  Even
  228. if you don't renew, you'll continue to receive commissions.
  229.  
  230. When you register, you may order a copy of the current version of
  231. ADA-TUTR, with your serial number.  The price is $5 for a 5.25"
  232. diskette, $10 for a 3.5" diskette, or free with your formatted
  233. diskette and a stamped, addressed diskette mailer.  If you would like
  234. an order form or a price list, please print the file INVOICE.TXT.
  235.  
  236. We offer a Customization Kit that lets you edit, add, and delete
  237. ADA-TUTR screens, questions, etc. (even whole topics), producing a new
  238. ADA_TUTR.DAT file.  See the last paragraph on page 4.  Note that the
  239. Customization Kit is not Shareware.
  240.  
  241. We sell anywhere in the Free World.  We're sorry, but we don't yet
  242. accept credit cards.  Outside the U.S., please remit in U.S. funds and
  243. contact us about extra postal charges on diskettes.
  244.  
  245.  
  246. COMPANIES, SCHOOLS, AND OTHER ORGANIZATIONS:  Please see our special
  247. offer for Multi-User Licenses, on the next page.
  248.  
  249.                                                                Page  3
  250.  
  251.                SPECIAL OFFER TO COMPANIES, SCHOOLS, ETC.
  252.  
  253. ADA-TUTR can be of great benefit to your company, school, or other
  254. organization.  We encourage you to try ADA-TUTR before paying for it,
  255. and you may install ADA-TUTR on your workstations and mainframes as
  256. well as your PCs!  Instructions for installing ADA-TUTR on other
  257. computers are on page 43.
  258.  
  259. If you decide to use ADA-TUTR, you could register each individual
  260. user, as described on page 2.  But if you have more than 18 users, you
  261. can save money by buying a Multi-User License, as described here.
  262. You're on your honor; you know whether you're "using" ADA-TUTR or only
  263. "trying" it.  Multi-User Licenses are very reasonably priced, as
  264. follows:
  265.  
  266.  
  267.  Number of Users:  Price of License:               Note:
  268.  
  269.     Up to  100        only  $450      Send $5 extra for a copy of the
  270.     Up to  500        only  $725      latest version of ADA-TUTR on a
  271.     Up to 2000        only  $950      5.25" diskette, $10 extra for a
  272.     Unlimited         only $2400      copy on a 3.5" diskette.
  273.  
  274.  
  275. A license may always be upgraded for only the difference in price.
  276.  
  277. A sample Multi-User license appears on pages 40-41.  A Multi-User
  278. License gives the specified number of people the right to use ADA-TUTR
  279. as long as you like, on all your computers (from small PCs to large
  280. mainframes), at all your locations.  We use the term Multi-User
  281. License rather than Site License because there are no geographic
  282. restrictions.  (Note: If 100 people use ADA-TUTR now and 100 others
  283. use it later, that counts as 200 users, not 100.)  Sales commissions
  284. are NOT paid to Multi-User Licensees.
  285.  
  286. A Multi-User License includes one year of technical support, which can
  287. be renewed for only 10% of the price of the license per year.  While
  288. you have technical support, we'll inform you of any important updates
  289. to ADA-TUTR, and send you an updated copy on a 5.25" diskette for only
  290. $5 ($10 for a 3.5" diskette).  The update is free if you send your own
  291. blank, formatted diskette and a stamped, addressed diskette mailer.
  292. We're planning a major update of ADA-TUTR with the next revision (9X)
  293. of the Ada language.
  294.  
  295. Even if you don't renew your Technical Support, you'll still have the
  296. right to use ADA-TUTR as long as you like.
  297.  
  298. Please print the file INVOICE.TXT, or use your own form.  (When
  299. ordering, please give us the serial number from the opening screen of
  300. your copy of ADA-TUTR, if you have one.)
  301.  
  302. We accept Purchase Orders.  Our Federal tax ID number is 360-40-8382,
  303. and we qualify as a Small Business.  We sell anywhere in the Free
  304. World.  We're sorry, but we don't yet accept credit cards.  Outside
  305. the U.S., please remit in U.S. funds and contact us about extra postal
  306. charges on diskettes.
  307.  
  308.                                                                Page  4
  309.  
  310. With Shareware, you never have to worry about software piracy, because
  311. your people are ENCOURAGED to copy and distribute the program!  If you
  312. prefer, however, a conventional (non-Shareware) version of ADA-TUTR is
  313. available at the same prices.
  314.  
  315. If you buy a license, we'll be happy to do minor customization of
  316. ADA-TUTR for you at no charge.  For example, we can add your company
  317. name to the opening screen.  If you'd like major customization,
  318. contact us for terms, or buy our Customization Kit for $195.  Using
  319. any text editor on a PC or mainframe, the Customization Kit lets you
  320. edit, add, and delete screens, questions, etc. (even whole topics),
  321. producing a new ADA_TUTR.DAT file.  The Customization Kit isn't
  322. Shareware, but you may copy it for use throughout your organization as
  323. required.
  324.  
  325.                                                                Page  5
  326.  
  327.                       NOTE TO COMPILER COMPANIES
  328.  
  329. A Commercial version of ADA-TUTR is available, without the Shareware
  330. notices and without the list of Ada compilers.  It can be customized
  331. for your company, and can run on almost any Ada platform, including
  332. workstations and mainframes, because Ada source code is included.
  333. ADA-TUTR can greatly increase the sales appeal of your compilers and
  334. your Ada tools, whether you sell it separately or include it with your
  335. products.  Please contact us.
  336.  
  337. If you're a prospective contractor or subcontractor, the Commercial or
  338. Shareware version of ADA-TUTR may be the best and most economical way
  339. for you to supply your customer's Ada educational needs.  Please
  340. contact us before writing your proposal.
  341.  
  342.                                                                Page  6
  343.  
  344.   DOES YOUR SCREEN SHOW STRANGE CHARACTERS LIKE ARROWS AND BRACKETS?
  345.  
  346. Give the command TYPE READ.ME on your PC.  If one word appears
  347. brighter than the rest, you can skip this page.  However, if your
  348. screen shows strange characters like "[1m" when you TYPE READ.ME or
  349. run ADA_TUTR, you need to read this.
  350.  
  351. ADA-TUTR uses ANSI (American National Standards Institute) escape
  352. sequences for highlighting, cursor positioning, reverse video, etc.
  353. Before ADA-TUTR will work correctly on a PC, you must install the
  354. device driver ANSI.SYS, which came with your copy of DOS.  To install
  355. ANSI.SYS, do the following:
  356.  
  357. 1.  If there's a file CONFIG.SYS in the root directory of the disk
  358.     from which you boot, type it and look for a line saying
  359.     "DEVICE=ANSI.SYS" (without the quotes), in either upper or lower
  360.     case.  If that line is not present, add it to CONFIG.SYS anywhere
  361.     in the file, using an ordinary text editor or word processor in
  362.     the non-document mode.  If there's no CONFIG.SYS file, create one
  363.     containing the single line "DEVICE=ANSI.SYS" (without the quotes).
  364.  
  365. 2.  If there's no file ANSI.SYS in your root directory, copy ANSI.SYS
  366.     from your DOS distribution diskette to the root directory of the
  367.     disk from which you boot.
  368.  
  369. 3.  Reboot the computer.  ADA-TUTR should then work correctly.
  370.  
  371.                                                                Page  7
  372.  
  373.                        THE ADA RESERVED WORDS
  374.  
  375. The 63 reserved words are listed in the Language Reference Manual in
  376. section 2.9, and are repeated here for convenience.
  377.  
  378.   abort         declare        generic      of             select
  379.   abs           delay          goto         or             separate
  380.   accept        delta                       others         subtype
  381.   access        digits         if           out
  382.   all           do             in                          task
  383.   and                          is           package        terminate
  384.   array                                     pragma         then
  385.   at            else                        private        type
  386.                 elsif          limited      procedure
  387.                 end            loop
  388.   begin         entry                       raise          use
  389.   body          exception                   range
  390.                 exit           mod          record         when
  391.                                             rem            while
  392.                                new          renames        with
  393.   case          for            not          return
  394.   constant      function       null         reverse        xor
  395.  
  396.                                                                Page  8
  397.  
  398.          STEPS FOR OUTSIDE ASSIGNMENT 1, PREPARING TO RUN ADA
  399.  
  400. For the first Outside Assignment, learn enough about your Ada compiler
  401. to compile and run the two simple programs HELLO.ADA and ADD.ADA.
  402. Obviously, you have to do this before you can do the remaining Outside
  403. Assignments.
  404.  
  405. 1.  Compile HELLO.ADA.  On most systems, after the Ada compiler is
  406. installed and your library is created, this only involves typing
  407. ADA HELLO or ADA HELLO.ADA.  On some systems, the compiler is invoked
  408. from a menu or "APSE" (Ada Programming Support Environment).
  409.  
  410. 2.  Link, giving the name of the main program, HELLO.  This usually
  411. involves typing LINK HELLO or BIND HELLO, perhaps with some options.
  412. On one system, the command is BAMP HELLO, for Build Ada Main Program!
  413.  
  414. 3.  Run the program.  If your Ada compiler produces native code on a
  415. PC, it created a file HELLO.EXE, and this step simply involves typing
  416. HELLO.  On other systems, the command RUN HELLO is appropriate.  On
  417. some systems, you have to invoke an interpreter to run the program.
  418.  
  419. 4.  Now compile, link, and run ADD.ADA.
  420.  
  421. If your compiler implements a subset of Ada, you may have to modify
  422. the programs in this and later Outside Assignments to get them to
  423. compile.  Some subset Ada compilers don't allow "separate" compilation
  424. (used in later assignments), and you'll have to include the "separate"
  425. subprograms inside the main program and compile them as one.  Some
  426. subset compilers don't allow generic instantiation, and have another
  427. way of displaying integers.  In that case, you'll have to modify
  428. ADD.ADA.  If you're using a validated compiler, you won't have to
  429. worry about any of this, because all of the Outside Assignments are
  430. written in standard Ada.
  431.  
  432.                                                                Page  9
  433.  
  434. HELLO.ADA
  435. ---------
  436.  
  437. with TEXT_IO; use TEXT_IO;
  438. procedure HELLO is
  439. begin
  440.    PUT_LINE("Hello!");
  441. end HELLO;
  442.  
  443.  
  444.  
  445. ADD.ADA
  446. -------
  447.  
  448. with TEXT_IO; use TEXT_IO;
  449. procedure ADD is
  450.    package MY_INT_IO is new INTEGER_IO(INTEGER); use MY_INT_IO;
  451. begin
  452.    PUT(2 + 2);
  453.    NEW_LINE;
  454. end ADD;
  455.  
  456.                                                                Page 10
  457.  
  458. TRITEST.ADA
  459. -----------
  460.  
  461. with TEXT_IO; use TEXT_IO;
  462. procedure TRITEST is
  463.    PASSED : BOOLEAN := TRUE;
  464.    type TRIANGLE is (EQUILATERAL, ISOSCELES, SCALENE, NOT_A_TRIANGLE);
  465.    function TRITYPE(LEN1, LEN2, LEN3 : in INTEGER) return TRIANGLE
  466.                                                           is separate;
  467.    procedure COMPARE(A, B, C: in INTEGER; RIGHT_ANSWER : in TRIANGLE)
  468.                                                           is separate;
  469. begin
  470.    COMPARE( 3,  4,  5, SCALENE);
  471.    COMPARE( 6,  3,  4, SCALENE);
  472.    COMPARE( 4,  3,  6, SCALENE);
  473.    COMPARE( 3,  3,  3, EQUILATERAL);
  474.    COMPARE( 3,  3,  4, ISOSCELES);
  475.    COMPARE( 3,  4,  3, ISOSCELES);
  476.    COMPARE( 4,  3,  3, ISOSCELES);
  477.    COMPARE( 7,  7,  4, ISOSCELES);
  478.    COMPARE( 7,  4,  7, ISOSCELES);
  479.    COMPARE( 4,  7,  7, ISOSCELES);
  480.    COMPARE( 1,  1,  1, EQUILATERAL);
  481.    COMPARE( 0,  4,  4, NOT_A_TRIANGLE);
  482.    COMPARE( 4,  0,  4, NOT_A_TRIANGLE);
  483.    COMPARE( 4,  4,  0, NOT_A_TRIANGLE);
  484.    COMPARE( 0,  4,  3, NOT_A_TRIANGLE);
  485.    COMPARE( 3,  0,  4, NOT_A_TRIANGLE);
  486.    COMPARE( 4,  3,  0, NOT_A_TRIANGLE);
  487.    COMPARE(-1,  4,  4, NOT_A_TRIANGLE);
  488.    COMPARE( 4, -1,  4, NOT_A_TRIANGLE);
  489.    COMPARE( 4,  4, -1, NOT_A_TRIANGLE);
  490.    COMPARE(-1,  4,  3, NOT_A_TRIANGLE);
  491.    COMPARE( 3, -1,  4, NOT_A_TRIANGLE);
  492.    COMPARE( 4,  3, -1, NOT_A_TRIANGLE);
  493.    COMPARE( 2,  4,  6, NOT_A_TRIANGLE);
  494.    COMPARE( 1,  3,  2, NOT_A_TRIANGLE);
  495.    COMPARE( 3,  1,  2, NOT_A_TRIANGLE);
  496.    COMPARE( 1,  2,  4, NOT_A_TRIANGLE);
  497.    COMPARE( 1,  4,  2, NOT_A_TRIANGLE);
  498.    COMPARE( 4,  1,  2, NOT_A_TRIANGLE);
  499.    COMPARE( 0,  0,  0, NOT_A_TRIANGLE);
  500.    COMPARE( 0,  0,  4, NOT_A_TRIANGLE);
  501.    COMPARE( 0,  4,  0, NOT_A_TRIANGLE);
  502.    COMPARE( 4,  0,  0, NOT_A_TRIANGLE);
  503.    COMPARE( 3,  3,  7, NOT_A_TRIANGLE);
  504.    COMPARE( 3,  7,  3, NOT_A_TRIANGLE);
  505.    COMPARE( 6,  3,  3, NOT_A_TRIANGLE);
  506.    COMPARE(-3, -4, -5, NOT_A_TRIANGLE);
  507.    if PASSED then
  508.       PUT_LINE("Congratulations, you completed the assignment!");
  509.    end if;
  510. end TRITEST;
  511.                            -- continued --
  512.  
  513.                                                                Page 11
  514.  
  515. separate (TRITEST)
  516. procedure COMPARE(A, B, C: in INTEGER; RIGHT_ANSWER : in TRIANGLE) is
  517.    package INT_IO is new INTEGER_IO(INTEGER); use INT_IO;
  518.    package TRI_IO is new ENUMERATION_IO(TRIANGLE); use TRI_IO;
  519.    MY_ANSWER : TRIANGLE := TRITYPE(A, B, C);
  520. begin
  521.    if MY_ANSWER /= RIGHT_ANSWER then
  522.       PUT("Sides:");
  523.       PUT(A, WIDTH => 3);
  524.       PUT(B, WIDTH => 3);
  525.       PUT(C, WIDTH => 3);
  526.       PUT("   My answer: ");
  527.       PUT(MY_ANSWER, WIDTH => 14);
  528.       PUT("   Right answer: ");
  529.       PUT(RIGHT_ANSWER);
  530.       NEW_LINE;
  531.       PASSED := FALSE;
  532.    end if;
  533. end COMPARE;
  534.  
  535.                                                                Page 12
  536.  
  537.     STEPS FOR OUTSIDE ASSIGNMENT 2, EXERCISE IN ENUMERATION TYPES
  538.  
  539. 1.  Compile the test driver TRITEST.ADA.  Also, make a copy of the
  540.     dummy solution by typing COPY TRITYPE.DUM TRITYPE.ADA.  You need
  541.     do this step only once.
  542.  
  543. 2.  Edit TRITYPE.ADA to become your real solution.  You can skip this
  544.     step the first time through, to see error messages from the test
  545.     driver.
  546.  
  547. 3.  Compile your solution TRITYPE.ADA.  If the compiler finds errors,
  548.     go back to step 2.
  549.  
  550. 4.  Link with the name of the main program TRITEST.  Then execute.  If
  551.     the test driver displays error messages, go back to step 2.
  552.  
  553. 5.  When the message "Congratulations, you completed the assignment!"
  554.     is displayed, you'll have a chance to compare your solution with
  555.     ours.
  556.  
  557.                                                                Page 13
  558.  
  559. NEXTDATE.ADA
  560. ------------
  561.  
  562. with TEXT_IO; use TEXT_IO;
  563. procedure NEXTDATE is
  564.    type MONTH_TYPE is
  565.       (JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC);
  566.    subtype DAY_SUBTYPE is INTEGER range 1 .. 31;
  567.    type DATE is
  568.       record
  569.          DAY   : DAY_SUBTYPE;
  570.          MONTH : MONTH_TYPE;
  571.          YEAR  : POSITIVE;
  572.       end record;
  573.    PASSED : BOOLEAN := TRUE;
  574.    function TOMORROW(TODAY : in DATE) return DATE is separate;
  575.  
  576.    procedure DISPLAY (S : in STRING; D : in DATE) is
  577.       package INT_IO is new INTEGER_IO(INTEGER); use INT_IO;
  578.    begin
  579.       PUT(S);
  580.       PUT(D.DAY, WIDTH => 3);
  581.       PUT(" " & MONTH_TYPE'IMAGE(D.MONTH));
  582.       PUT(D.YEAR, WIDTH => 5);
  583.       NEW_LINE;
  584.    end DISPLAY;
  585.    procedure COMPARE(TODAY, RIGHT_ANSWER : in DATE) is
  586.       MY_ANSWER : DATE := TOMORROW(TODAY);
  587.    begin
  588.       if MY_ANSWER /= RIGHT_ANSWER then
  589.          DISPLAY("Today:       ", TODAY);
  590.          DISPLAY("My answer:   ", MY_ANSWER);
  591.          DISPLAY("Right answer:", RIGHT_ANSWER);
  592.          NEW_LINE;
  593.          PASSED := FALSE;
  594.       end if;
  595.    end COMPARE;
  596. begin
  597.    COMPARE((12,DEC,1815), (13,DEC,1815)); -- ordinary date
  598.    COMPARE(( 3,FEB,1986), ( 4,FEB,1986)); -- ordinary date in Feb.
  599.    COMPARE((30,JUN,1981), ( 1,JUL,1981)); -- last day of 30-day month
  600.    COMPARE((30,SEP,3999), ( 1,OCT,3999)); -- last day of 30-day month
  601.    COMPARE((31,MAR,1876), ( 1,APR,1876)); -- last day of 31-day month
  602.    COMPARE((31,AUG,1984), ( 1,SEP,1984)); -- last day of 31-day month
  603.    COMPARE((31,DEC,1966), ( 1,JAN,1967)); -- last day of year
  604.    COMPARE((28,FEB,1980), (29,FEB,1980)); -- leap year
  605.    COMPARE((28,FEB,1600), (29,FEB,1600)); -- century leap year
  606.    COMPARE((28,FEB,2200), ( 1,MAR,2200)); -- century non-leap year
  607.    COMPARE((28,FEB,1982), ( 1,MAR,1982)); -- non-leap year
  608.    COMPARE((29,FEB,1980), ( 1,MAR,1980)); -- leap day in leap year
  609.    if PASSED then
  610.       PUT_LINE("Congratulations, you completed the assignment!");
  611.    end if;
  612. end NEXTDATE;
  613.  
  614.                                                                Page 14
  615.  
  616.          STEPS FOR OUTSIDE ASSIGNMENT 3, EXERCISE IN RECORDS
  617.  
  618. 1.  Compile the test driver NEXTDATE.ADA.  Also, make a copy of the
  619.     dummy solution by typing COPY TOMORROW.DUM TOMORROW.ADA.  You need
  620.     do this step only once.
  621.  
  622. 2.  Edit TOMORROW.ADA to become your real solution.  You can skip this
  623.     step the first time through, to see error messages from the test
  624.     driver.
  625.  
  626. 3.  Compile TOMORROW.ADA.  If the compiler finds errors, go back to
  627.     step 2.
  628.  
  629. 4.  Link with the name of the main program NEXTDATE.  Then execute.
  630.     If the test driver displays error messages, go back to step 2.
  631.  
  632. 5.  When the message "Congratulations, you completed the assignment!"
  633.     is displayed, you'll have a chance to compare your solution with
  634.     ours.
  635.  
  636.                                                                Page 15
  637.  
  638. FIBTEST.ADA
  639. -----------
  640.  
  641. with TEXT_IO; use TEXT_IO;
  642. procedure FIBTEST is
  643.    PASSED : BOOLEAN := TRUE;
  644.    function FIB(N : in POSITIVE) return POSITIVE is separate;
  645.    procedure COMPARE (N : in POSITIVE; RIGHT_ANSWER : in POSITIVE) is
  646.       package INT_IO is new INTEGER_IO(INTEGER); use INT_IO;
  647.       MY_ANSWER : POSITIVE := FIB(N);
  648.    begin
  649.       if MY_ANSWER /= RIGHT_ANSWER then
  650.          PUT("N:");  PUT(N);
  651.          PUT("          My answer:");  PUT(MY_ANSWER);
  652.          PUT("          Right answer:");  PUT(RIGHT_ANSWER);
  653.          NEW_LINE;
  654.          PASSED := FALSE;
  655.       end if;
  656.    end COMPARE;
  657. begin
  658.    COMPARE(1, 1);
  659.    COMPARE(2, 1);
  660.    COMPARE(3, 2);
  661.    COMPARE(4, 3);
  662.    COMPARE(5, 5);
  663.    COMPARE(6, 8);
  664.    COMPARE(7, 13);
  665.    COMPARE(10, 55);
  666.    COMPARE(15, 610);
  667.    COMPARE(20, 6765);
  668.    if PASSED then
  669.       PUT_LINE("Congratulations, you completed the assignment!");
  670.    end if;
  671. end FIBTEST;
  672.  
  673.                                                                Page 16
  674.  
  675.         STEPS FOR OUTSIDE ASSIGNMENT 4, EXERCISE IN RECURSION
  676.  
  677. 1.  Compile the test driver FIBTEST.ADA.  Also, make a copy of the
  678.     dummy solution by typing COPY FIB.DUM FIB.ADA.  You need do this
  679.     step only once.
  680.  
  681. 2.  Edit FIB.ADA to become your real solution.  You can skip this step
  682.     the first time through, to see error messages from the test
  683.     driver.
  684.  
  685. 3.  Compile FIB.ADA.  If the compiler finds errors, go back to step 2.
  686.  
  687. 4.  Link with the name of the main program FIBTEST.  Then execute.  If
  688.     the test driver displays error messages, go back to step 2.
  689.  
  690. 5.  When the message "Congratulations, you completed the assignment!"
  691.     is displayed, you'll have a chance to compare your solution with
  692.     ours.
  693.  
  694.                                                                Page 17
  695.  
  696. SIMPLIFIED SPECIFICATION FOR TEXT_IO
  697. ------------------------------------
  698.  
  699. package TEXT_IO is
  700.    type FILE_TYPE is limited private;
  701.  
  702.    type FILE_MODE is (IN_FILE, OUT_FILE);
  703.    type COUNT is ... (a user-defined type similar to INTEGER);
  704.    STATUS_ERROR, MODE_ERROR, NAME_ERROR, END_ERROR : exception;
  705.  
  706.    procedure CREATE      (FILE : in out FILE_TYPE;
  707.                           MODE : in FILE_MODE := OUT_FILE;
  708.                           NAME : in STRING);
  709.  
  710.    procedure OPEN        (FILE : in out FILE_TYPE;
  711.                           MODE : in FILE_MODE;
  712.                           NAME : in STRING);
  713.  
  714.    procedure CLOSE       (FILE : in out FILE_TYPE);
  715.    procedure DELETE      (FILE : in out FILE_TYPE);
  716.    procedure NEW_LINE    (SPACING : in COUNT := 1);
  717.    procedure NEW_LINE    (FILE : in FILE_TYPE;
  718.                           SPACING : in COUNT := 1);
  719.    procedure SKIP_LINE   (SPACING : in COUNT := 1);
  720.    procedure SKIP_LINE   (FILE : in FILE_TYPE;
  721.                           SPACING : in COUNT := 1);
  722.    function  END_OF_FILE (FILE : in FILE_TYPE) return BOOLEAN;
  723.    procedure PUT         (ITEM : in CHARACTER);
  724.    procedure PUT         (FILE : in FILE_TYPE; ITEM : in CHARACTER);
  725.    procedure GET         (ITEM : out CHARACTER);
  726.    procedure GET         (FILE : in FILE_TYPE; ITEM : out CHARACTER);
  727.    procedure PUT         (ITEM : in STRING);
  728.    procedure PUT         (FILE : in FILE_TYPE; ITEM : in STRING);
  729.    procedure PUT_LINE    (ITEM : in STRING);
  730.    procedure PUT_LINE    (FILE : in FILE_TYPE; ITEM : in STRING);
  731.    procedure GET_LINE    (ITEM : out STRING; LAST : out NATURAL);
  732.    procedure GET_LINE    (FILE : in FILE_TYPE;
  733.                           ITEM : out STRING;
  734.                           LAST : out NATURAL);
  735.    generic
  736.       type NUM is range <>;
  737.    package INTEGER_IO is
  738.       procedure GET (ITEM : out NUM);
  739.       procedure GET (FILE : in FILE_TYPE; ITEM : out NUM);
  740.       procedure PUT (ITEM  : in NUM;
  741.                      WIDTH : in INTEGER := ...;
  742.                      BASE  : in INTEGER := 10);
  743.       procedure PUT (FILE  : in FILE_TYPE;
  744.                      ITEM  : in NUM;
  745.                      WIDTH : in INTEGER := ...;
  746.                      BASE  : in INTEGER := 10);
  747.    end INTEGER_IO;
  748.  
  749.                            -- continued --
  750.  
  751.                                                                Page 18
  752.  
  753.    generic
  754.       type NUM is digits <>;
  755.    package FLOAT_IO is
  756.       procedure GET (ITEM : out NUM);
  757.       procedure GET (FILE : in FILE_TYPE; ITEM : out NUM);
  758.       procedure PUT (ITEM : in NUM;
  759.                      FORE : in INTEGER := 2;
  760.                      AFT  : in INTEGER := ...;
  761.                      EXP  : in INTEGER := 3);
  762.       procedure PUT (FILE : in FILE_TYPE;
  763.                      ITEM : in NUM;
  764.                      FORE : in INTEGER := 2;
  765.                      AFT  : in INTEGER := ...;
  766.                      EXP  : in INTEGER := 3);
  767.    end FLOAT_IO;
  768.  
  769.    generic
  770.       type ENUM is (<>);
  771.    package ENUMERATION_IO is
  772.       procedure GET (ITEM : out ENUM);
  773.       procedure GET (FILE : in FILE_TYPE; ITEM : out ENUM);
  774.       procedure PUT (ITEM : in ENUM; WIDTH : in INTEGER := 0);
  775.       procedure PUT (FILE : in FILE_TYPE;
  776.                      ITEM : in ENUM; WIDTH : in INTEGER := 0);
  777.    end ENUMERATION_IO;
  778.  
  779. private
  780.  
  781.    type FILE_TYPE is ... (implementation dependent);
  782.  
  783. end TEXT_IO;
  784.  
  785.                                                                Page 19
  786.  
  787. Program to copy a simple text file:
  788. -----------------------------------
  789.  
  790. with TEXT_IO; use TEXT_IO;
  791. procedure FILECOPY is
  792.    F1, F2 : FILE_TYPE;
  793.    S      : STRING(1 .. 80);
  794.    LEN    : INTEGER;
  795. begin
  796.    PUT("Input file: ");  GET_LINE(S, LEN);
  797.    OPEN(FILE => F1, MODE => IN_FILE, NAME => S(1 .. LEN));
  798.    PUT("Output file: ");  GET_LINE(S, LEN);
  799.    CREATE(FILE => F2, MODE => OUT_FILE, NAME => S(1 .. LEN));
  800.    while not END_OF_FILE(F1) loop
  801.       GET_LINE(F1, S, LEN);
  802.       PUT_LINE(F2, S(1 .. LEN));
  803.    end loop;
  804.    CLOSE(F1);
  805.    CLOSE(F2);
  806. end FILECOPY;
  807.  
  808.  
  809.  
  810. Function to test if a text file exists:
  811. ---------------------------------------
  812.  
  813. with TEXT_IO; use TEXT_IO;
  814. function EXISTS(FILE_NAME : in STRING) return BOOLEAN is
  815.    F      : FILE_TYPE;
  816.    ANSWER : BOOLEAN := TRUE;
  817. begin
  818.    begin
  819.       OPEN(F, IN_FILE, FILE_NAME);
  820.       CLOSE(F);
  821.    exception
  822.       when NAME_ERROR => ANSWER := FALSE;
  823.    end;
  824.    return ANSWER;
  825. end EXISTS;
  826.  
  827.                                                                Page 20
  828.  
  829.                  REQUIREMENTS FOR THE PROGRAM LEDIT
  830.  
  831. This assignment will give you practice in writing a program of greater
  832. complexity than the previous programs you've written.  Imagine that
  833. your screen editor is unavailable to a particular user, perhaps
  834. because he's dialing your computer from a remote location, and your
  835. screen editor writes directly to the screen.  You want to write a very
  836. simple line editor, LEDIT, that could be used in such circumstances.
  837. While your computer already has a line editor called EDLIN, it's
  838. difficult to learn to use.  LEDIT will take almost no effort to learn.
  839. The only commands are LIST and EXIT!  The line editor edits by means
  840. of line numbers, similar to the Basic language.
  841.  
  842. The user begins each line of text that he types with a line number
  843. from 1 to 29999.  Line numbers must be integers.  The upper limit
  844. 29999 was chosen so that the simple type INTEGER could be used - in
  845. any implementation of Ada.   Regardless of the order in which lines
  846. are typed, LEDIT maintains a linked list of lines in order by number.
  847. Also, line numbers may be preceded by any number of spaces.  For
  848. example, if the user types
  849.  
  850. 40 -- This is a comment.
  851.    20 begin
  852. 10 with TEXT_IO; use TEXT_IO;
  853.       30 end ADD;
  854.  
  855. and then types LIST, the editor will type
  856.  
  857.    10 with TEXT_IO; use TEXT_IO;
  858.    20 begin
  859.    30 end ADD;
  860.    40 -- This is a comment.
  861.  
  862. To INSERT lines, the user merely types lines with intermediate line
  863. numbers.  For example, if he types
  864.  
  865. 15 procedure HELLO is
  866.  
  867. and then types LIST, LEDIT will type
  868.  
  869.    10 with TEXT_IO; use TEXT_IO;
  870.    15 procedure HELLO is
  871.    20 begin
  872.    30 end ADD;
  873.    40 -- This is a comment.
  874.  
  875. To REPLACE an existing line, the user merely types a line with the
  876. same line number as the line to be replaced.  For example, if he typed
  877.  
  878. 15 procedure ADD is
  879. LIST
  880.  
  881.  
  882.                            -- continued --
  883.  
  884.                                                                Page 21
  885.  
  886. LEDIT would then show
  887.  
  888.    10 with TEXT_IO; use TEXT_IO;
  889.    15 procedure ADD is
  890.    20 begin
  891.    30 end ADD;
  892.    40 -- This is a comment.
  893.  
  894. Finally, to DELETE a line, the user merely types the number of the
  895. line to be deleted, followed immediately by a carriage return.  Typing
  896.  
  897. 40
  898. LIST
  899.  
  900. would then produce
  901.  
  902.    10 with TEXT_IO; use TEXT_IO;
  903.    15 procedure ADD is
  904.    20 begin
  905.    30 end ADD;
  906.  
  907. Thus the user can INSERT, REPLACE, and DELETE lines, all by line
  908. numbers, without learning any commands.  Note that in this simple
  909. editor there is no "cursor" and no "current line."
  910.  
  911. The space is not required after the line number.  These two lines have
  912. exactly the same effect:
  913.  
  914. 20 begin
  915. 20begin
  916.  
  917. Of course, if the text of the line begins with a digit, a space will
  918. be required to separate it from the line number.  In any event, LEDIT
  919. always leaves one blank space after the line number when LISTing, for
  920. readability.  It always allows exactly five spaces for the line number
  921. itself.
  922.  
  923. However, any EXTRA spaces typed after the line number are significant.
  924. The three lines below each contain three EXTRA spaces after the line
  925. number, for a total of four spaces.
  926.  
  927. 24    PUT(2 + 2);
  928. 26    NEW_LINE;
  929. 18    package MY_INT_IO is new INTEGER_IO(INTEGER); use MY_INT_IO;
  930.  
  931. They have the effect of indenting the text three spaces.  LIST now
  932. shows
  933.  
  934.  
  935.                            -- continued --
  936.  
  937.                                                                Page 22
  938.  
  939.    10 with TEXT_IO; use TEXT_IO;
  940.    15 procedure ADD is
  941.    18    package MY_INT_IO is new INTEGER_IO(INTEGER); use MY_INT_IO;
  942.    20 begin
  943.    24    PUT(2 + 2);
  944.    26    NEW_LINE;
  945.    30 end ADD;
  946.  
  947. Although typing a line number followed immediately by a carriage
  948. return deletes a line (if there is a line by that number), typing a
  949. line number followed by a single space causes an empty line to be
  950. introduced into the file.  For example, typing 12 followed by a single
  951. space and a carriage return would then cause LIST to type
  952.  
  953.    10 with TEXT_IO; use TEXT_IO;
  954.    12
  955.    15 procedure ADD is
  956.    18    package MY_INT_IO is new INTEGER_IO(INTEGER); use MY_INT_IO;
  957.    20 begin
  958.    24    PUT(2 + 2);
  959.    26    NEW_LINE;
  960.    30 end ADD;
  961.  
  962. When LEDIT is run, it prompts for the names of the input and output
  963. files.  If the input file exists, LEDIT displays "File found" and
  964. reads the file into its linked list, assigning line numbers starting
  965. with 10 and incrementing by 10.  If the file does not exist, LEDIT
  966. displays "File not found," and the linked list is initially empty.  In
  967. any event, LEDIT creates an output file.  When the EXIT command is
  968. given, LEDIT writes the contents of the linked list to the output
  969. file.  In doing so, LEDIT removes the line numbers and the first blank
  970. after each line number.
  971.  
  972. In the example above, let us assume that the user typed ADD.ADA for an
  973. output file name.  When he types EXIT, the new file ADD.ADA created by
  974. LEDIT will contain:
  975.  
  976. with TEXT_IO; use TEXT_IO;
  977.  
  978. procedure ADD is
  979.    package MY_INT_IO is new INTEGER_IO(INTEGER); use MY_INT_IO;
  980. begin
  981.    PUT(2 + 2);
  982.    NEW_LINE;
  983. end ADD;
  984.  
  985. (Note that the file contains one empty line.)  Your program is not
  986. allowed to add any trailing blanks of its own in the output file.  If
  987. the user again runs LEDIT and specifies ADD.ADA as an input file, the
  988. editor will type "File found" and read the file.  LIST will then show
  989.  
  990.  
  991.                            -- continued --
  992.  
  993.                                                                Page 23
  994.  
  995.    10 with TEXT_IO; use TEXT_IO;
  996.    20
  997.    30 procedure ADD is
  998.    40    package MY_INT_IO is new INTEGER_IO(INTEGER); use MY_INT_IO;
  999.    50 begin
  1000.    60    PUT(2 + 2);
  1001.    70    NEW_LINE;
  1002.    80 end ADD;
  1003.  
  1004. When he EXITs, the new file will contain modified text.  The old file
  1005. will still be present until it is deleted.
  1006.  
  1007. The two commands LIST and EXIT must be accepted in either upper or
  1008. lower case, but for simplicity, they need not be accepted in a mixture
  1009. of cases.  They may be preceded by any number of spaces.  The LIST
  1010. command must be accepted in any of the following forms:
  1011.  
  1012. LIST            (Lists all lines, if any, otherwise does nothing.)
  1013. list 30         (Lists line 30, if it exists.)
  1014. list 25 - 35    (Lists all lines between 25 and 35 inclusive, if any.)
  1015. LIST - 35       (Lists all lines numbered 35 or less, if any.)
  1016. list 25 -       (Lists all lines numbered 25 or more, if any.)
  1017.  
  1018. Furthermore, all spaces are optional in the LIST command provided that
  1019. LIST is written solid, so that LIST25-35 is equivalent to the third
  1020. example above.  Any other forms of LIST should be flagged as an error.
  1021. In particular, all of these should give error messages:
  1022.  
  1023. LIST -
  1024. list 2A
  1025. LIST 30 - 50 -
  1026. list 30 - -50
  1027. list 30-A
  1028. LIST XYZ
  1029.  
  1030. The EXIT command must stand alone; unlike LIST, EXIT is never followed
  1031. by anything.  Except for the LIST and EXIT commands, every line typed
  1032. must begin with a number between 1 and 29999.  (Of course, the user
  1033. should be able to type just a carriage return with no effect.)  LEDIT
  1034. should check that line numbers are in range when adding or replacing
  1035. lines.  The LIST command need not check the range of the line numbers,
  1036. because it should be impossible to create lines with improper numbers.
  1037. Your program need not handle input files so long that 29999 would be
  1038. exceeded when it assigns line numbers starting at 10 with an increment
  1039. of 10.
  1040.  
  1041. Your LEDIT must prompt for input and output file names at the start,
  1042. and it may display a prompt for each line that the user types.  You
  1043. may assume some maximum length for an input line (e.g., 80), and
  1044. assume that no file will have lines longer than the maximum.  You may
  1045. also assume that no file will have special characters like form feeds.
  1046.  
  1047.  
  1048.                            -- continued --
  1049.  
  1050.                                                                Page 24
  1051.  
  1052. For simplicity, there's no way to edit a line except by retyping it.
  1053. Also, there's no way to copy or move a line or a block of lines, and
  1054. no way to delete a block of lines except one line at a time.  There's
  1055. no RENUMBER command.  The user can renumber the entire file starting
  1056. at 10 with an increment of 10 by EXITing and then rerunning LEDIT.
  1057. There's no AUTO command to make the editor type the line numbers
  1058. automatically while text is being typed by the user, and there's no
  1059. means of recovering from a system crash that occurs during an edit.
  1060. Additionally, there's no way to search for a string, or replace one
  1061. string with another.  These features would all be desirable, but we
  1062. feel that Outside Assignment 5 is challenging as it stands.
  1063.  
  1064. You're encouraged to use Ada's "separate" compilation feature, so that
  1065. you don't have to recompile the entire program when developing a
  1066. module.
  1067.  
  1068. As a point of reference, our solution to this assignment consists of
  1069. about 180 lines of code on four pages.  If you have any questions
  1070. about what LEDIT should do, you can compile and run our solution,
  1071. which is in LEDIT.ANS.
  1072.  
  1073. The following declarations are offered by way of suggestion only, and
  1074. you should use them only if you feel comfortable with them:
  1075.  
  1076.      MAX_LENGTH : constant INTEGER := 80;
  1077.      type TEXT is
  1078.         record
  1079.            LEN : INTEGER range 0 .. MAX_LENGTH;
  1080.            VAL : STRING(1 .. MAX_LENGTH);
  1081.         end record;
  1082.  
  1083.      type LINK;
  1084.      type P is access LINK;
  1085.      type LINK is
  1086.         record
  1087.            NUM  : POSITIVE;
  1088.            LINE : TEXT;
  1089.            NEXT : P;
  1090.         end record;
  1091.  
  1092.      function STR(T : in TEXT) return STRING;
  1093.  
  1094. In our solution, we used type TEXT as above.  However, we didn't write
  1095. a TEXT_HANDLER package, because it didn't seem to be needed.  We used
  1096. a one-page main program with several "separate" subprograms.
  1097.  
  1098.                                                                Page 25
  1099.  
  1100.     STEPS FOR OUTSIDE ASSIGNMENT 5, WRITING A SIMPLE LINE EDITOR
  1101.  
  1102. 1.  Carefully read the requirements starting on page 20 of these
  1103.     notes.  Take your time.
  1104.  
  1105. 2.  Write the Ada code, compile, and link.  Call the main program
  1106.     LEDIT.  If you have any questions about what LEDIT should do, you
  1107.     can compile and run our solution, which is in LEDIT.ANS.
  1108.  
  1109. 3.  Refer to pages 26-28 of these notes for instructions on testing
  1110.     your line editor.  If any tests are failed, go back to step 2.
  1111.  
  1112. 4.  When all the tests are passed, you've completed the assignment and
  1113.     will have a chance to compare your solution with ours.
  1114.  
  1115.                                                                Page 26
  1116.  
  1117.                           HOW TO TEST LEDIT
  1118.  
  1119. 1.  Run LEDIT and give the name of an input file that doesn't exist.
  1120. LEDIT should say "File not found."  Give another name of a file that
  1121. doesn't exist for an output file.
  1122.  
  1123. 2.  Type "LIST" (without the quotes) to make sure that LEDIT can
  1124. handle the LIST command when no text has been entered.
  1125.  
  1126. 3.  Type "EXI".  The program should NOT exit.  If it exits, it's
  1127. probably because the "T" was left in the input buffer from the LIST
  1128. command.  Your program is checking the first four characters of the
  1129. input buffer without checking the length of the typed command.
  1130.  
  1131. 4.  Type "ABC".  The program should display a message about an illegal
  1132. or unrecognized command, or syntax error.
  1133.  
  1134. 5.  Type "0X" (zero followed by X).  The program should reject this
  1135. line, displaying a message about an invalid line number.  Type "0 X".
  1136. The same thing should happen.  Try "30000X", then "30000 X", and then
  1137. "3000000000 X".  The program should reject these, as well.
  1138.  
  1139. 6.  Type "-1 X" and "-1X".  The program should reject these lines,
  1140. displaying a message either about an unrecognized command (or syntax
  1141. error), or an invalid line number.
  1142.  
  1143. 7.  Type a simple carriage return.  There should be no effect, except
  1144. for any prompt being repeated.
  1145.  
  1146. 8.  Type the following exactly as shown.  Note that lines 1000 and 100
  1147. each contain four spaces:
  1148.  
  1149. 30 X
  1150. 1 The
  1151. 29999 ZZZZZZZZ
  1152. 1000    used
  1153. 100    is
  1154. 10000 to test
  1155.    30file --
  1156. 1 This
  1157.     29999 LEDIT.
  1158.  
  1159. 9.  Type "list".  You should see the following, lined up exactly as
  1160. shown.  There should be exactly five spaces for the line numbers.
  1161.  
  1162.     1 This
  1163.    30 file --
  1164.   100    is
  1165.  1000    used
  1166. 10000 to test
  1167. 29999 LEDIT.
  1168.  
  1169.  
  1170.                            -- continued --
  1171.  
  1172.                                                                Page 27
  1173.  
  1174. 10.  Try a line of text beginning with a number: "20000 123 45".  Then
  1175. type "   LIST" with three leading spaces.  You should see
  1176.  
  1177.     1 This
  1178.    30 file --
  1179.   100    is
  1180.  1000    used
  1181. 10000 to test
  1182. 20000 123 45
  1183. 29999 LEDIT.
  1184.  
  1185. 11.  Insert an empty line by typing "15000 ".  Then type "LIST".  You
  1186. should see
  1187.  
  1188.     1 This
  1189.    30 file --
  1190.   100    is
  1191.  1000    used
  1192. 10000 to test
  1193. 15000
  1194. 20000 123 45
  1195. 29999 LEDIT.
  1196.  
  1197. 12.  Type "EXIT ABC".  LEDIT should display a error message and NOT
  1198. exit.  The requirements say that the EXIT command must stand alone.
  1199.  
  1200. 13.  Type "   exit".  LEDIT should exit, and you should have a new
  1201. file with the output file name you gave in step 1.  Type the file with
  1202. the TYPE command.  You should see exactly this, starting in column 1:
  1203.  
  1204. This
  1205. file --
  1206.    is
  1207.    used
  1208. to test
  1209.  
  1210. 123 45
  1211. LEDIT.
  1212.  
  1213. 14.  Run LEDIT again, using for an input file the name of the OUTPUT
  1214. file you specified in step 1.  This time the program should say "File
  1215. found."  Choose yet another name for an output file for this step.
  1216. Type "list".  You should see the following, exactly as shown:
  1217.  
  1218.    10 This
  1219.    20 file --
  1220.    30    is
  1221.    40    used
  1222.    50 to test
  1223.    60
  1224.    70 123 45
  1225.    80 LEDIT.
  1226.  
  1227.                            -- continued --
  1228.  
  1229.                                                                Page 28
  1230.  
  1231. 15.  Type "  LIST 30".  You should see only line 30.  Type
  1232. "list25-45".  You should see only lines 30 and 40.  Type "LIST  - 40".
  1233. You should see lines 10 through 40.  Type "list35 -".  You should see
  1234. lines 40 through 80.  Type "list 15".  The program should either do
  1235. nothing or display a message that line 15 doesn't exist.  Try
  1236. "list 30000" and "list 3000000000".  Again, the program should either
  1237. do nothing or display an error message.  Now type "list" and check
  1238. that the result is the same as in step 14.
  1239.  
  1240. 16.  Try each of the following.  In each case, LEDIT should display an
  1241. error message:
  1242.  
  1243. LIST -
  1244. list 2A
  1245. list 30 - 50 -
  1246. list 30 - -50
  1247.    list 30-A
  1248. LIST XYZ
  1249.  
  1250. 17.  Type "70" to delete line 70.  Type "LIST".  You should see
  1251.  
  1252.    10 This
  1253.    20 file --
  1254.    30    is
  1255.    40    used
  1256.    50 to test
  1257.    60
  1258.    80 LEDIT.
  1259.  
  1260. 18.  Delete line 60.  Do not list.  Now delete line 80 and list.  You
  1261. should see
  1262.  
  1263.    10 This
  1264.    20 file --
  1265.    30    is
  1266.    40    used
  1267.    50 to test
  1268.  
  1269. 19.  Delete line 10 and list.  You should see lines 20 through 50
  1270. above.  Delete line 50 and list.  You should see lines 20 through 40.
  1271. Delete line 30 and list.  You should see lines 20 and 40.  Delete line
  1272. 40 and list.  You should see only line 20.  Delete line 20 and list.
  1273. The result should be the same as in step 2.  Type "EXIT".
  1274.  
  1275. 20.  If your program passed all these tests, sincere congratulations!
  1276. You've completed a difficult assignment.  We hope that you feel
  1277. comfortable with Ada now.  If you like, you can compare your solution
  1278. with ours, starting on page 29 of these notes.  When you go back to
  1279. ADA-TUTR, you'll learn to write your own generic packages, procedures,
  1280. and functions.
  1281.  
  1282.                                                                Page 29
  1283.  
  1284. LEDIT.ANS
  1285. ---------
  1286.  
  1287. -- Our solution to Outside Assignment 5:
  1288. with TEXT_IO; use TEXT_IO;
  1289. procedure LEDIT is
  1290.    MAX_LENGTH      : constant := 80;
  1291.    MAX_LINE_NUMBER : constant := 29_999;
  1292.    type TEXT is
  1293.       record
  1294.          LEN : INTEGER range 0 .. MAX_LENGTH := 0;
  1295.          VAL : STRING(1 .. MAX_LENGTH);
  1296.       end record;
  1297.    type LINK;
  1298.    type P is access LINK;
  1299.    type LINK is
  1300.       record
  1301.          NUM  : POSITIVE;
  1302.          LINE : TEXT;
  1303.          NEXT : P;
  1304.       end record;
  1305.    HEAD            : P := new LINK;
  1306.    TEMP            : P;
  1307.    INPUT_FILE      : FILE_TYPE;
  1308.    OUTPUT_FILE     : FILE_TYPE;
  1309.    INPUT           : TEXT;
  1310.    FINISHED        : BOOLEAN := FALSE;
  1311.    LINE_NUM        : NATURAL := 10;
  1312.  
  1313.    function  STR(T : in TEXT) return STRING is separate;
  1314.    procedure READ_INPUT_FILE is separate;
  1315.    procedure DO_COMMAND is separate;
  1316. begin
  1317.    PUT("Input file: ");  GET_LINE(INPUT.VAL, INPUT.LEN);
  1318.    READ_INPUT_FILE;
  1319.    PUT("Output file: ");  GET_LINE(INPUT.VAL, INPUT.LEN);
  1320.    CREATE(OUTPUT_FILE, NAME => STR(INPUT));
  1321.  
  1322.    -- Get and process commands.
  1323.    while not FINISHED loop
  1324.       PUT("> ");  GET_LINE(INPUT.VAL, INPUT.LEN);
  1325.       DO_COMMAND;
  1326.    end loop;
  1327.  
  1328.    -- Write the output file.
  1329.    TEMP := HEAD.NEXT;     -- Skip unused link at start of linked list.
  1330.    while TEMP /= null loop
  1331.       PUT_LINE(OUTPUT_FILE, STR(TEMP.LINE));    -- Write line of text.
  1332.       TEMP := TEMP.NEXT;                             -- Get next link.
  1333.    end loop;
  1334.    CLOSE(OUTPUT_FILE);
  1335. end LEDIT;
  1336.  
  1337.                            -- continued --
  1338.  
  1339.                                                                Page 30
  1340.  
  1341. separate (LEDIT)
  1342. function STR(T : in TEXT) return STRING is
  1343. begin
  1344.    return T.VAL(1 .. T.LEN);
  1345. end STR;
  1346.  
  1347. separate (LEDIT)
  1348. procedure READ_INPUT_FILE is
  1349. begin   -- If the input file exists, display a message and read it in.
  1350.    OPEN(INPUT_FILE, IN_FILE, STR(INPUT));
  1351.    PUT_LINE("File found.");
  1352.    TEMP := HEAD;
  1353.    while not END_OF_FILE(INPUT_FILE) loop
  1354.       GET_LINE(INPUT_FILE, INPUT.VAL, INPUT.LEN);      -- Read a line.
  1355.       TEMP.NEXT := new LINK'(LINE_NUM, INPUT, null);   -- Add to list.
  1356.       TEMP := TEMP.NEXT;              -- Advance pointer to next link.
  1357.       LINE_NUM := LINE_NUM + 10;
  1358.    end loop;
  1359.    CLOSE(INPUT_FILE);
  1360. exception  -- If the input file doesn't exist, just display a message.
  1361.    when NAME_ERROR => PUT_LINE("File not found.");
  1362. end READ_INPUT_FILE;
  1363.  
  1364. separate (LEDIT)
  1365. procedure DO_COMMAND is
  1366.    procedure DELETE_FIRST_CHARACTER(T : in out TEXT) is separate;
  1367.    procedure GET_LEADING_INTEGER(N : out NATURAL) is separate;
  1368.    procedure STRIP_LEADING_SPACES_FROM_INPUT is separate;
  1369.    procedure ADD_DELETE_REPLACE_LINE is separate;
  1370.    procedure LIST is separate;
  1371. begin
  1372.    STRIP_LEADING_SPACES_FROM_INPUT;
  1373.    if STR(INPUT) = "exit" or STR(INPUT) = "EXIT" then
  1374.       FINISHED := TRUE;
  1375.    elsif INPUT.LEN >= 4 and (INPUT.VAL(1 .. 4) = "list" or
  1376.                                INPUT.VAL(1 .. 4) = "LIST") then
  1377.       LIST;
  1378.    elsif INPUT.LEN > 0 and INPUT.VAL(1) not in '0' .. '9' then
  1379.       PUT_LINE("Unrecognized command.");
  1380.    elsif INPUT.LEN > 0 then
  1381.       GET_LEADING_INTEGER(LINE_NUM);
  1382.       if LINE_NUM not in 1 .. MAX_LINE_NUMBER then
  1383.          PUT_LINE("Illegal line number.");
  1384.       else
  1385.          ADD_DELETE_REPLACE_LINE;
  1386.       end if;
  1387.    end if;
  1388. exception
  1389.    when NUMERIC_ERROR | CONSTRAINT_ERROR =>
  1390.       PUT_LINE("Line number too large.");
  1391. end DO_COMMAND;
  1392.  
  1393.  
  1394.                            -- continued --
  1395.  
  1396.                                                                Page 31
  1397.  
  1398. separate (LEDIT.DO_COMMAND)
  1399. procedure ADD_DELETE_REPLACE_LINE is
  1400.    INP : TEXT := INPUT;
  1401. begin
  1402.    if INP.LEN > 0 and INP.VAL(1) = ' ' then  -- Treat "9x" like "9 x".
  1403.       DELETE_FIRST_CHARACTER(INP);
  1404.    end if;
  1405.    TEMP := HEAD;     -- Find where this number belongs in linked list.
  1406.    while TEMP /= null and then TEMP.NEXT /= null and then
  1407.                                TEMP.NEXT.NUM <= LINE_NUM loop
  1408.       if TEMP.NEXT.NUM = LINE_NUM then
  1409.          TEMP.NEXT := TEMP.NEXT.NEXT;                  -- Delete line.
  1410.       else
  1411.          TEMP := TEMP.NEXT;           -- Advance to next link in list.
  1412.       end if;
  1413.    end loop;
  1414.    if INPUT.LEN > 0 then                                  -- Add line.
  1415.       TEMP.NEXT := new LINK'(LINE_NUM, INP, TEMP.NEXT);
  1416.    end if;
  1417. end ADD_DELETE_REPLACE_LINE;
  1418.  
  1419. separate (LEDIT.DO_COMMAND)
  1420. procedure DELETE_FIRST_CHARACTER(T : in out TEXT) is
  1421. begin
  1422.    T.VAL(1 .. T.LEN - 1) := T.VAL(2 .. T.LEN);
  1423.    T.LEN := T.LEN - 1;
  1424. end DELETE_FIRST_CHARACTER;
  1425.  
  1426. separate (LEDIT.DO_COMMAND)
  1427. procedure GET_LEADING_INTEGER(N : out NATURAL) is
  1428.    ANS: INTEGER := 0;
  1429. begin
  1430.    while INPUT.LEN > 0 and INPUT.VAL(1) in '0' .. '9' loop
  1431.       ANS := ANS*10 + CHARACTER'POS(INPUT.VAL(1)) -CHARACTER'POS('0');
  1432.       DELETE_FIRST_CHARACTER(INPUT);
  1433.    end loop;
  1434.    N := ANS;
  1435. end GET_LEADING_INTEGER;
  1436.  
  1437. separate (LEDIT.DO_COMMAND)
  1438. procedure STRIP_LEADING_SPACES_FROM_INPUT is
  1439. begin
  1440.    while INPUT.LEN > 0 and INPUT.VAL(1) = ' ' loop
  1441.       DELETE_FIRST_CHARACTER(INPUT);
  1442.    end loop;
  1443. end STRIP_LEADING_SPACES_FROM_INPUT;
  1444.  
  1445.  
  1446.                            -- continued --
  1447.  
  1448.                                                                Page 32
  1449.  
  1450. separate (LEDIT.DO_COMMAND)
  1451. procedure LIST is
  1452.    package IIO is new INTEGER_IO(INTEGER); use IIO;
  1453.    START, FINISH : NATURAL;
  1454.    VALID         : BOOLEAN := TRUE;
  1455. begin
  1456.    INPUT.LEN := INPUT.LEN - 4;      -- Delete the name of the command.
  1457.    INPUT.VAL(1 .. INPUT.LEN) := INPUT.VAL(5 .. INPUT.LEN + 4);
  1458.    STRIP_LEADING_SPACES_FROM_INPUT;
  1459.    if INPUT.LEN = 0 then          -- For "LIST" alone, list all lines.
  1460.       START := 0;
  1461.       FINISH := MAX_LINE_NUMBER + 1;
  1462.    else
  1463.       GET_LEADING_INTEGER(START);          -- Get number after "LIST".
  1464.       STRIP_LEADING_SPACES_FROM_INPUT;
  1465.       if INPUT.LEN = 0 then         -- For "LIST n", list only line n.
  1466.          FINISH := START;
  1467.       elsif INPUT.VAL(1) /= '-' then        -- Else "-" must follow n.
  1468.          VALID := FALSE;
  1469.       else
  1470.          DELETE_FIRST_CHARACTER(INPUT);             -- Delete the "-".
  1471.          STRIP_LEADING_SPACES_FROM_INPUT;
  1472.          GET_LEADING_INTEGER(FINISH);         -- Get number after "-".
  1473.          STRIP_LEADING_SPACES_FROM_INPUT;
  1474.          if FINISH = 0 and START = 0 then     -- "LIST -" isn't valid.
  1475.             VALID := FALSE;
  1476.          elsif FINISH = 0 then  -- For "LIST n -", list n through end.
  1477.             FINISH := MAX_LINE_NUMBER + 1;
  1478.          end if;
  1479.          VALID := VALID  and  INPUT.LEN = 0;   -- No trailing garbage.
  1480.       end if;
  1481.    end if;
  1482.    if not VALID then
  1483.       PUT_LINE("Illegal syntax for LIST.");
  1484.    else
  1485.       TEMP := HEAD.NEXT;  -- Skip unused link at start of linked list.
  1486.       while TEMP /= null and then TEMP.NUM <= FINISH loop
  1487.          if TEMP.NUM >= START then
  1488.             PUT(TEMP.NUM, WIDTH => 5);     -- Display line #, width 5.
  1489.             PUT_LINE(' ' & STR(TEMP.LINE));   -- Display text of line.
  1490.          end if;
  1491.          TEMP := TEMP.NEXT;                          -- Get next link.
  1492.       end loop;
  1493.    end if;
  1494. exception
  1495.    when NUMERIC_ERROR | CONSTRAINT_ERROR =>
  1496.       PUT_LINE("Line number too large in LIST.");
  1497. end LIST;
  1498.  
  1499.                                                                Page 33
  1500.  
  1501. TASKING.DUM
  1502. -----------
  1503.  
  1504. with text_io, calendar; use text_io, calendar;
  1505. procedure tasking is
  1506.    interval        : constant duration := 5.0;
  1507.    total_intervals : constant positive := 9;
  1508.    start_time      : constant time := clock;
  1509.    quitting_time   : constant time := start_time +
  1510.                                              total_intervals*interval;
  1511.    next_time       : time := start_time;
  1512.    task type tick is
  1513.       entry make_noise;
  1514.       entry shutdown;
  1515.    end tick;
  1516.    t               : tick;
  1517.    task body tick is
  1518.       quit : boolean := false;
  1519.    begin
  1520.       while not quit loop
  1521.          select
  1522.             accept make_noise do
  1523.                put_line("Tick!");
  1524.             end make_noise;
  1525.          or
  1526.             accept shutdown;
  1527.             quit := true;
  1528.          end select;
  1529.       end loop;
  1530.    end tick;
  1531. begin
  1532.    while next_time < quitting_time loop
  1533.       t.make_noise;
  1534.       next_time := next_time + interval;
  1535.       put_line("(5-second delay)"); delay next_time - clock;
  1536.    end loop;
  1537.    t.shutdown;
  1538. end tasking;
  1539.  
  1540.                                                                Page 34
  1541.  
  1542.          STEPS FOR OUTSIDE ASSIGNMENT 6, EXERCISE IN TASKING
  1543.  
  1544. 1.  Make a copy of TASKING.DUM by typing COPY TASKING.DUM TASKING.ADA.
  1545.     Compile, link, and execute the program to make sure it displays
  1546.     "Tick!" nine times, with a 5-second delay after each "Tick."
  1547.  
  1548. 2.  Edit TASKING.ADA to become your solution.  Make your changes in
  1549.     upper case.
  1550.  
  1551. 3.  Compile TASKING.ADA, link, and execute.
  1552.  
  1553. 4.  Compare your output with page 35 of these notes.  If there are any
  1554.     errors, go back to step 2.
  1555.  
  1556. 5.  When your output agrees with these notes, you've finished the
  1557.     assignment and will have a chance to compare your solution with
  1558.     ours.
  1559.  
  1560.                                                                Page 35
  1561.  
  1562.       OUTPUT FROM TASKING.EXE AFTER MODIFICATION OF TASKING.ADA
  1563.  
  1564. C>tasking
  1565. Task number 1 is starting.
  1566. Task number 2 is starting.
  1567. Task number 3 is starting.
  1568. (5-second delay)
  1569. (5-second delay)
  1570. Task number 1 is starting.
  1571. (5-second delay)
  1572. Task number 2 is starting.
  1573. (5-second delay)
  1574. Task number 1 is starting.
  1575. Task number 3 is starting.
  1576. (5-second delay)
  1577. (5-second delay)
  1578. Task number 1 is starting.
  1579. Task number 2 is starting.
  1580. (5-second delay)
  1581. (5-second delay)
  1582. Task number 1 is starting.
  1583. Task number 3 is starting.
  1584. (5-second delay)
  1585.  
  1586. C>
  1587.  
  1588.                                                                Page 36
  1589.  
  1590. TASKING.ANS
  1591. -----------
  1592.  
  1593. -- Our solution to Outside Assignment 6:
  1594. with text_io, calendar; use text_io, calendar;
  1595. procedure tasking is
  1596.    interval        : constant duration := 5.0;
  1597.    total_intervals : constant positive := 9;
  1598.    start_time      : constant time := clock;
  1599.    quitting_time   : constant time := start_time +
  1600.                                              total_intervals*interval;
  1601.    next_time       : time := start_time;
  1602.    task type tick is
  1603.       ENTRY IDENTIFY(TASK_NUMBER : IN NATURAL);
  1604.       entry shutdown;
  1605.    end tick;
  1606.    T               : ARRAY(1 .. 3) OF TICK;
  1607.    PERIOD          : CONSTANT ARRAY(T'RANGE) OF POSITIVE := (2, 3, 4);
  1608.    TIMER           : ARRAY(T'RANGE) OF NATURAL := (OTHERS => 0);
  1609.    task body tick is
  1610.       quit : boolean := false;
  1611.    begin
  1612.       while not quit loop
  1613.          select
  1614.             ACCEPT IDENTIFY(TASK_NUMBER : IN NATURAL) DO
  1615.                PUT_LINE("Task number" & INTEGER'IMAGE(TASK_NUMBER) &
  1616.                     " is starting.");
  1617.             END IDENTIFY;
  1618.          or
  1619.             accept shutdown;
  1620.             quit := true;
  1621.          end select;
  1622.       end loop;
  1623.    end tick;
  1624. begin
  1625.    while next_time < quitting_time loop
  1626.       FOR I IN T'RANGE LOOP
  1627.          IF TIMER(I) = 0 THEN
  1628.             T(I).IDENTIFY(I);
  1629.             TIMER(I) := PERIOD(I);
  1630.          END IF;
  1631.          TIMER(I) := TIMER(I) - 1;
  1632.       END LOOP;
  1633.       next_time := next_time + interval;
  1634.       put_line("(5-second delay)"); delay next_time - clock;
  1635.    end loop;
  1636.    FOR I IN T'RANGE LOOP
  1637.       T(I).SHUTDOWN;
  1638.    END LOOP;
  1639. end tasking;
  1640.  
  1641.                                                                Page 37
  1642.  
  1643.   APPENDIX A:  WOULD YOU LIKE A TEXTBOOK TO USE ALONG WITH ADA-TUTR?
  1644.  
  1645. ADA-TUTR doesn't require a textbook, but a number of users have asked
  1646. us to recommend a book that would go well with this course.  We made a
  1647. special arrangement with John Wiley and Sons so that you can buy the
  1648. excellent textbook RENDEZVOUS WITH ADA by David Naiditch for only
  1649. $34.95 plus sales tax.  Simply print the file COUPON.TXT, or copy the
  1650. coupon below.  Please send it to the address on the coupon, not to
  1651. Software Innovations Technology.
  1652.  
  1653. +--------------------------------------------------------------------+
  1654. |                                                                    |
  1655. | If you would like to have a textbook to go along with ADA-TUTR,    |
  1656. | send this coupon to                                                |
  1657. |                                                                    |
  1658. |                   Attn.: Diane Dooley, 4th floor                   |
  1659. |                       Wiley - Training Sales                       |
  1660. |                        John Wiley and Sons                         |
  1661. |                          605 Third Avenue                          |
  1662. |                        New York, NY  10158                         |
  1663. |                                                                    |
  1664. | Please send me ______ copy(ies) of RENDEZVOUS WITH ADA by David    |
  1665. | Naiditch, to examine for 15 days.                                  |
  1666. |                                                                    |
  1667. | Order #: 1-61654-0.  Price: $34.95 plus local sales tax, postage   |
  1668. | and handling.                                                      |
  1669. |                                                                    |
  1670. | [ ]  Bill me.                                                      |
  1671. |                                                                    |
  1672. | [ ]  Payment enclosed.  (Orders accompanied by payment will be     |
  1673. |      sent postpaid.)                                               |
  1674. |                                                                    |
  1675. | [ ]  Charge my   ___ VISA   ___ MasterCard   ___ American Express  |
  1676. |      (Note: Credit card orders are not considered prepayment.)     |
  1677. |                                                                    |
  1678. |      Account #: ________________________________                   |
  1679. |                                                                    |
  1680. |      Expiration Date: __________________________                   |
  1681. |                                                                    |
  1682. | NAME:____________________________ AFFILIATION:____________________ |
  1683. |                                                                    |
  1684. | ADDRESS:__________________________________________________________ |
  1685. |                                                                    |
  1686. | CITY/STATE/ZIP:_____________________ SIGNATURE:___________________ |
  1687. |                                  (Offer invalid without signature) |
  1688. |                                                                    |
  1689. | (Prices subject to change without notice and higher outside the    |
  1690. | U.S.A.)                                                            |
  1691. |                                                                    |
  1692. +--------------------------------------------------------------------+
  1693.  
  1694.                                                                Page 38
  1695.  
  1696.           APPENDIX B:  RUNNING BOOK TO PRINT ALL THE SCREENS
  1697.  
  1698. If you're running ADA-TUTR on a PC, you can always print the screen
  1699. that's currently being displayed by holding a Shift key while pressing
  1700. the PrtSc key.
  1701.  
  1702. However, several users wanted to be able to print ALL the screens in
  1703. the entire course, as one large book.  So, starting with version 2.0
  1704. of ADA-TUTR, we added the program BOOK.  This program reads the file
  1705. ADA_TUTR.DAT and produces two large output files, which can then be
  1706. printed.  Be prepared to print almost 500 pages!
  1707.  
  1708. Simply type BOOK to run the program.  BOOK first asks you if you'll be
  1709. using PC-Write to print the files.  (See page 42 for information about
  1710. PC-Write.)
  1711.  
  1712. If you answer Y, BOOK will put PC-Write "boldface" commands in the
  1713. output files.  Thus the text will print in boldface wherever you see
  1714. emphasized text on the screen.
  1715.  
  1716.  
  1717. However, if you answer N, BOOK will create plain ASCII files, double
  1718.                                                               ------
  1719. spaced the way this paragraph is double spaced.  It will emphasize
  1720. ------                           -------------           ---------
  1721. text by placing hyphens below the lines like this.
  1722.                 -------                 ---------
  1723.  
  1724. Next, BOOK will ask you for the name of the output file for the first
  1725. half of the tutorial.  After that file is written, BOOK will ask for
  1726. the name of the output file for the second half of the tutorial.  You
  1727. can then print the output files.
  1728.  
  1729. If you're not using PC-Write, you can optionally specify the name PRN
  1730. for both output files, and the output of BOOK will go directly to the
  1731. printer.
  1732.  
  1733. Begin reading your printed output with Screen 104.  Note that, at the
  1734. bottom of each page, there's a list of possible user responses with
  1735. screen numbers.  For example, at the bottom of Screen 104 you will see
  1736.  
  1737.   'Y' 107  'N' 120
  1738.  
  1739. This means that, if the user presses Y, he will next see Screen 107,
  1740. and if the user presses N, he will next see Screen 120.  Pressing X
  1741. always takes the user to Screen 103.  The special "screen numbers" 098
  1742. through 100 appearing at the bottom of Screens 107 and 108 are
  1743. explained in the introductory comments in ADA_TUTR.ADA.
  1744.  
  1745. BOOK, like ADA-TUTR, will run on a PC or on any Ada-speaking computer.
  1746.  
  1747.                                                                Page 39
  1748.  
  1749.          APPENDIX C:  SOME ADA COMPILERS AVAILABLE FOR THE PC
  1750.  
  1751. Here's a brief list of Ada compilers available for the IBM PC and
  1752. compatibles.  For this course, an Ada compiler is helpful, but not
  1753. required.  There are six Outside Assignments; most of them ask you to
  1754. write and compile a short Ada program.  If you don't have access to an
  1755. Ada compiler, just skip the Outside Assignments.
  1756.  
  1757. Although we may now have a small financial interest in some of the
  1758. companies mentioned here (see page 5), we try to keep this list
  1759. unbiased.  If you know of an Ada compiler for the PC that should be on
  1760. this list, or if you have any updated information or corrections,
  1761. please contact us.
  1762.  
  1763. 1.  At the low end of the scale is Augusta.  This compiler is in the
  1764.     public domain, and can be found on many computer bulletin boards.
  1765.     It's a very small subset of Ada with no packages.  It translates
  1766.     Ada to a P-code, and then interprets the P-code.  Some of the
  1767.     syntax is non-standard, such as "elseif" where Ada uses "elsif."
  1768.     Older versions of Augusta require Turbo Pascal.  Augusta isn't
  1769.     really adequate for most of the Outside Assignments of ADA-TUTR.
  1770.  
  1771. 2.  Janus/Ada is sold by R R Software, Inc., Box 1512, Madison, WI
  1772.     53701, phone 800-722-3248.  Prices start at $50 for an unvalidated
  1773.     compiler with limited memory size, intended for classroom use.
  1774.     Validated compilers start at $99.  A complete development system
  1775.     with tools (such as a debugger) and utility packages is available
  1776.     for $500, but it requires an 80386 computer.  Janus/Ada produces
  1777.     native PC code; no interpreter is required.
  1778.  
  1779. 3.  Desktop Ada is sold by GEM Technologies Computer Corp., 100 Main
  1780.     St., Old Saybrook, CT  06475, phone 800-232-3989, for $149.95.
  1781.     Tools and utility packages are included.  It's validated and
  1782.     produces native PC code; no interpreter is required.
  1783.  
  1784. 4.  Open Ada is sold by Meridian Software Systems, Inc., 10 Pasteur
  1785.     St., Irvine, CA  92718, phone 800-221-2522 (in CA, 714-727-0700),
  1786.     for $199 ($99 for students).  Open Ada includes tools (such as a
  1787.     debugger) and utility packages.  It's validated and produces
  1788.     native PC code; no interpreter is required.
  1789.  
  1790. 5.  IntegrAda is sold by Aetech, Inc., 5841 Edison Place, Suite 110,
  1791.     Carlsbad, CA  92008, phone 619-431-7714, for $395.  IntegrAda
  1792.     includes tools (such as a debugger) and utility packages.  It's
  1793.     validated and produces native PC code; no interpreter is required.
  1794.  
  1795. 6.  At the high end of the scale is FirstAda, sold by Alsys, Inc., 67
  1796.     South Bedford St., Burlington, MA  01803-9748, phone 617-270-0030.
  1797.     The price is $595 until 29 May 1992; as this is written (March,
  1798.     1992), Alsys hasn't decided on the price after that date.
  1799.     FirstAda is validated and requires a PC/AT (or compatible) with at
  1800.     least 2 MB of extended memory.  However, it can produce native
  1801.     code for the PC/XT; no interpreter is required.
  1802.  
  1803.                                                                Page 40
  1804.  
  1805.             APPENDIX D:  SAMPLE MULTI-USER SOFTWARE LICENSE
  1806.  
  1807. Software Innovations Technology believes in a plain-English software
  1808. license that people can understand.  A sample license appears on the
  1809. next page.  However, if your company's lawyers would prefer a
  1810. differently worded license, simply contact us.  We'll be happy to
  1811. accommodate you.
  1812.  
  1813. As you can see, the terms of our license are very generous.  We allow
  1814. you to make as many copies of ADA-TUTR as you like, and to install it
  1815. on as many computers as you like, regardless of the computer type
  1816. (laptop, desktop, workstation, mainframe, etc.)  Also, you may use
  1817. ADA-TUTR at all your geographical locations, which is why we use the
  1818. term Multi-User License rather than Site License.  The only thing we
  1819. limit is the total number of people who may use ADA-TUTR (except in
  1820. the case of an unlimited license).  Please remember that if 100 people
  1821. use ADA-TUTR now and 100 others use it later, that counts as 200
  1822. users, not 100.
  1823.  
  1824. In the sample license on the next page, comments appear in brackets.
  1825. These comments are not part of the actual license.
  1826.  
  1827.                                                                Page 41
  1828.  
  1829.                  [SAMPLE] MULTI-USER SOFTWARE LICENSE
  1830.  
  1831.                     Software Innovations Technology
  1832.                         1083 Mandarin Drive NE
  1833.                        Palm Bay, FL  32905-4706
  1834.                             (407) 951-0233
  1835.  
  1836.  
  1837.    This license conveys to XYZ Company the right to use the comput-
  1838.    er program  ADA-TUTR, the Interactive Ada Tutor,  under the fol-
  1839.    lowing conditions:
  1840.  
  1841.    1.  The program shall remain  the property of  Software  Innova-
  1842.    tions Technology.
  1843.  
  1844.    2.  The program may be freely copied and installed on any or all
  1845.    computers of  XYZ Company,  regardless of geographical location.
  1846.    Copies of the program may be distributed outside XYZ Company for
  1847.    others to evaluate on a trial basis.
  1848.  
  1849.    3.  This license is perpetual.
  1850.  
  1851.    4.  The number of  XYZ Company  personnel [or "students and per-
  1852.    sonnel of XYZ University"] who may use the program is unlimited.
  1853.                              [*** OR ***]
  1854.    4.  The total number of XYZ Company personnel  [or "students and
  1855.    personnel of  XYZ  University"]  who use the program,  excluding
  1856.    those who only briefly evaluate it, shall not exceed  two  thou-
  1857.    sand (2000)  [or "five hundred (500)"  or  "one hundred (100)"].
  1858.    In calculating the number of users,  XYZ Company must always add
  1859.    the number of people  currently  using the program to the number
  1860.    who have used it in the past.
  1861.  
  1862.    5.  [This paragraph is omitted in unlimited licenses.]  Software
  1863.    Innovations Technology  sells  licenses  for  larger  numbers of
  1864.    users.  XYZ Company may, at any time, upgrade this license for a
  1865.    larger number of users by paying,  to Software Innovations Tech-
  1866.    nology, the difference in price between the two licenses.
  1867.  
  1868.    6.  This license is not transferable.
  1869.  
  1870.    7.  The Disclaimer of Warranty, included in the program documen-
  1871.    tation, applies as if included in this license.
  1872.  
  1873.    8.  [This paragraph is  omitted  if the order is prepaid.]  This
  1874.    license shall be  void  if the invoice is not paid within thirty
  1875.    (30) days of the date of this license.
  1876.  
  1877.  
  1878.    (Signed)________________________________  Date _________________
  1879.  
  1880.            John J. Herro, President
  1881.            Software Innovations Technology
  1882.  
  1883.                                                                Page 42
  1884.  
  1885.       APPENDIX E:  DO YOU NEED A SCREEN EDITOR / WORD PROCESSOR?
  1886.  
  1887. The Outside Assignments will be much easier if you have a good screen
  1888. editor.  We've looked at many, and found PC-Write, a Shareware program
  1889. by Quicksoft of Seattle, WA to be the best screen editor as well as
  1890. word processor.  There's lots of on-line help, and the 50000-word
  1891. spelling checker can be turned on for editing letters and documents,
  1892. and off for editing source code.  We liked the idea of having to learn
  1893. only ONE program for both kinds of editing!  Unlike ADA-TUTR, PC-Write
  1894. runs only on PCs and compatibles, not on mainframes, etc.
  1895.  
  1896. We have no connection with Quicksoft, except for being a registered
  1897. user of PC-Write.  However, we'll be happy to send you a free copy of
  1898. the latest version of that excellent program, if you send us three
  1899. blank, formatted, 360K 5.25" diskettes or two 720K 3.5" diskettes, and
  1900. a stamped, addressed diskette mailer.  Or send us $15 for three 5.25"
  1901. diskettes, or $20 for two 3.5" diskettes.  The diskettes or fee covers
  1902. only our expenses; you must register your copy of PC-Write with
  1903. Quicksoft if you use it after a free trial.  We're sorry, but we're
  1904. allowed to send copies of PC-Write only to the U.S., Australia,
  1905. Canada, and New Zealand.
  1906.  
  1907. If you use PC-Write to edit Ada programs, you may find the file
  1908. ED.ADA, included with ADA-TUTR, to be helpful.  It allows typing many
  1909. Ada reserved words with a single keystroke.  For example, you can type
  1910. "procedure" by striking Alt-P.  See the file ED.ADA for more details.
  1911. PC-Write will automatically invoke ED.ADA whenever you edit a file
  1912. with the extension .ADA.
  1913.  
  1914.                                                                Page 43
  1915.  
  1916.          APPENDIX F:  INSTALLING ADA-TUTR ON OTHER COMPUTERS
  1917.  
  1918. Because source code is included with ADA-TUTR, you can install
  1919. ADA-TUTR on almost any computer that has an Ada compiler - from
  1920. compact units to large mainframes.  ADA-TUTR is written in Ada (of
  1921. course!), and Ada programs tend to be very portable.
  1922.  
  1923. The screen should have at least 24 rows of 80 characters each, and
  1924. should support the ANSI escape sequences for highlighting, reverse
  1925. video, cursor positioning, etc.  Almost all computers qualify.
  1926.  
  1927. You need a way to send text files from your PC to the other computer.
  1928. Files are usually sent to large mainframes with the program KERMIT,
  1929. which is in the public domain.  One version of KERMIT runs on the PC,
  1930. another on the mainframe.  The two communicate with each other.
  1931. Sometimes XMODEM or another protocol is used instead of KERMIT.
  1932.  
  1933. If a communications program is available on the PC but not on the
  1934. other computer, you can still send text files, but not as efficiently.
  1935. Connect your PC as a terminal and tell the other computer to copy the
  1936. keyboard to a new file.  For example, on a VAX computer running VMS,
  1937. the command is "COPY TT: filename.ext" (without the quotes).  Then
  1938. tell your communications program to send (or "upload") the file, using
  1939. ASCII protocol, and stripping line feeds.  After the file is sent,
  1940. type the appropriate end-of-file character for the other computer.  On
  1941. a VAX running VMS, you would type Control-Z.  Since this method of
  1942. file transfer doesn't do error checking, you may have to send each
  1943. file twice using two different names, and compare the two files with
  1944. each other on the other computer.  It's far better to use a
  1945. communications program on the other computer, if one is available.
  1946.  
  1947. OK, you have some means of sending text files.  You won't have to send
  1948. other kinds of files.  To install ADA-TUTR on the other computer, just
  1949. follow these steps:
  1950.  
  1951. 1.  Type DAT2TXT on the PC.  This will read the file ADA_TUTR.DAT,
  1952. which is not a text file, and create a new text file TUTOR.TXT, which
  1953. can be sent to the other computer.  DAT2TXT will probably take several
  1954. minutes to run.  Don't try to bypass this step even if you're able to
  1955. send non-text files.  It's important that you send TUTOR.TXT and not
  1956. ADA_TUTR.DAT, because the PC version of ADA_TUTR.DAT doesn't work on
  1957. some systems.
  1958.  
  1959. 2.  Decide where ADA-TUTR will reside on the other computer, so that
  1960. it will be available to all users.  For example, on a VAX computer
  1961. running VMS, the tutor is usually placed in SYS$INSTRUCTION.  It could
  1962. also be placed in SYS$MANAGER, etc.
  1963.  
  1964.                            -- continued --
  1965.  
  1966.                                                                Page 44
  1967.  
  1968. 3.  Send to the other computer all the files that come with ADA-TUTR,
  1969. except ADA_TUTR.DAT and the files ending in .EXE.  Be sure to send
  1970. TUTOR.TXT, created in step 1.  Don't try to send ADA_TUTR.DAT and the
  1971. .EXE files, because they're not text files.  Also note that ADA-TUTR
  1972. creates a file ADA_TUTR.USR the first time it's run.  Do NOT send that
  1973. file, because it also is not a text file.  If our file names are
  1974. illegal on the other system, you'll have to rename them as they're
  1975. sent.  (We haven't seen a system where our file names are illegal.)
  1976.  
  1977. 4.  If any of the file names ADA_TUTR.DAT, ADA_TUTR.USR, or TUTOR.TXT
  1978. are illegal on your system, edit the files ADA_TUTR.ADA, BOOK.ADA,
  1979. CHANGESN.ADA, and TXT2DAT.ADA to show new, legal file names.  Search
  1980. for the old file names and replace them with the new ones.
  1981.  
  1982. 5.  Note that each user will probably run ADA-TUTR from his own file
  1983. directory.  There will be a file ADA_TUTR.USR in each user's
  1984. directory, but all the other files will reside in a common area, such
  1985. as SYS$INSTRUCTION, etc.  Therefore, edit the files ADA_TUTR.ADA,
  1986. BOOK.ADA, CHANGESN.ADA, and TXT2DAT.ADA to show the full path name of
  1987. the file ADA_TUTR.DAT.  On a VAX system, for example, you might search
  1988. for the name ADA_TUTR.DAT and replace it with
  1989. SYS$INSTRUCTION:ADA_TUTR.DAT.
  1990.  
  1991. 6.  On one system we encountered, Ada source file names must end in .a
  1992. rather than .ADA.  If that's the case on your system, rename all the
  1993. .ADA files.
  1994.  
  1995. 7.  On the other computer, compile, link, and run TXT2DAT.ADA.  Some
  1996. systems call the linking step "binding."  This program will read
  1997. TUTOR.TXT and create ADA_TUTR.DAT on the other system.  If you wish,
  1998. you may then delete TUTOR.TXT.
  1999.  
  2000. 8.  If you're using VAX Ada, skip to page 46.  If you're using a UNIX
  2001. based system that has a C compiler with the ability to link into Ada
  2002. programs, skip to page 47.  Otherwise, continue with the next page.
  2003. If you're not certain, continue with the next page.
  2004.  
  2005.                            -- continued --
  2006.  
  2007.                                                                Page 45
  2008.  
  2009.  
  2010. 9.  Compile VANILLA.ADA, but don't try to link or run it.  This "plain
  2011. vanilla" file will work with any standard Ada compiler.
  2012.  
  2013. 10.  Compile ADA_TUTR.ADA.
  2014.  
  2015. 11.  Link, giving the name of the main program, ADA_TUTR.  This will
  2016. produce an executable file, which on most systems will be called
  2017. ADA_TUTR.EXE.  However, on a few systems the executable file will have
  2018. a strange name, so rename the executable file if necessary.
  2019.  
  2020. 12.  Run ADA-TUTR.  The command is usually ADA_TUTR or RUN ADA_TUTR.
  2021. Note that, on some systems, you'll have to strike ENTER (or RETURN or
  2022. NEW-LINE) after each response, even though the program says, "You need
  2023. not hit ENTER."  The reason is that some systems require you to strike
  2024. ENTER when they read the keyboard through TEXT_IO.  However, with
  2025. recent versions of TeleGen Ada, you don't have to hit ENTER.  Also
  2026. note that some of the tutorial text refers to commands that are meant
  2027. for a PC, such as COPY and PRINT.  These commands may have to be
  2028. varied slightly to work on your system.
  2029.  
  2030. 13.  Define a command so that each user will be able to run ADA-TUTR
  2031. easily.
  2032.  
  2033.  
  2034. We'll be happy to help you install ADA-TUTR and get it running, even
  2035. if you haven't registered or bought a license.  We want you to try
  2036. ADA-TUTR before paying for it.
  2037.  
  2038.                                                                Page 46
  2039.  
  2040.                    SPECIAL INSTRUCTIONS FOR VAX ADA
  2041.  
  2042. 9.  If you're using VAX Ada, compile VAX.ADA, but don't try to link or
  2043. run it.  The file VANILLA.ADA would work, but VAX.ADA makes it
  2044. unnecessary to strike RETURN after each response.  The reason is that
  2045. VAX.ADA gets characters from the keyboard by calling the System
  2046. Service routines, without going through TEXT_IO.
  2047.  
  2048. 10.  Compile ADA_TUTR.ADA.
  2049.  
  2050. 11.  Link, giving the name of the main program, ADA_TUTR.  The command
  2051. is ACS LINK ADA_TUTR.  This will produce an executable file,
  2052. ADA_TUTR.EXE.
  2053.  
  2054. 12.  Run ADA-TUTR by typing RUN ADA_TUTR.  Note that some of the
  2055. tutorial text refers to commands that are meant for a PC, such as COPY
  2056. and PRINT.  These commands may have to be varied slightly to work on
  2057. your system.  For example, when the text says to type
  2058. COPY TRITYPE.DUM TRITYPE.ADA, your users might have to type
  2059. COPY SYS$INSTRUCTION:TRITYPE.DUM TRITYPE.ADA.
  2060.  
  2061. 13.  Define a command so that each user will be able to run ADA-TUTR
  2062. easily.  For example, you might add the following line to SYLOGIN.COM:
  2063.  
  2064.             $ TEACHADA :== "RUN SYS$INSTRUCTION:ADA_TUTR"
  2065.  
  2066.  
  2067. We'll be happy to help you install ADA-TUTR and get it running, even
  2068. if you haven't registered or bought a license.  We want you to try
  2069. ADA-TUTR before paying for it.
  2070.  
  2071.                                                                Page 47
  2072.  
  2073.              SPECIAL INSTRUCTIONS FOR UNIX BASED SYSTEMS
  2074.  
  2075. 9.  If you're using a UNIX based system with a C compiler, and your
  2076. Ada compiler can link with modules produced by C, compile ONECHAR.C
  2077. with the C compiler.  If you can't compile ONECHAR.C because your
  2078. system doesn't have the include file TERMIO.H, then compile ALTCHAR.C
  2079. instead.  However, if you compile ALTCHAR.C, you'll have to invoke
  2080. ADA-TUTR between two calls to stty, in a script file.  For example:
  2081.                      stty raw
  2082.                      /usr/local/ada-tutr/ada_tutr
  2083.                      stty -raw
  2084.  
  2085. 10.  Compile UNIX.ADA, but don't try to link or run it.  The file
  2086. VANILLA.ADA would work, but UNIX.ADA, when used with ONECHAR.C or
  2087. ALTCHAR.C, makes it unnecessary to strike RETURN after each response.
  2088. The reason is that ONECHAR.C and ALTCHAR.C get characters directly
  2089. from the keyboard, without going through TEXT_IO.
  2090.  
  2091. 11.  Compile ADA_TUTR.ADA.
  2092.  
  2093. 12.  Link, giving the name of the main program, ADA_TUTR.  Include the
  2094. object file from the C compiler in the link.  This will create an
  2095. executable file, called ADA_TUTR on most systems.  (On one system we
  2096. encountered, the file created was named a.out.)  If necessary, rename
  2097. the executable file to an appropriate name, such as ada_tutr or
  2098. ADA_TUTR or ADA_TUTR.EXE.
  2099.  
  2100.  
  2101. Here are sample steps 9 through 12 for two UNIX based systems:
  2102.  
  2103.        ON A UNISYS 5000/80:             ON A HARRIS HCX:
  2104.  
  2105.        cc -c onechar.c                  cc -c onechar.c
  2106.        ada unix.ada ada_tutr.ada        ada unix.a ada_tutr.a
  2107.        ald -p'onechar' ada_tutr         a.ld ada_tutr onechar.o
  2108.                                         mv a.out ada_tutr
  2109.  
  2110.  
  2111. 13.  Run ADA-TUTR.  Usually this is done by typing ada_tutr.  Note
  2112. that some of the tutorial text refers to commands that are meant for a
  2113. PC, such as COPY and PRINT.  These commands may have to be varied
  2114. slightly to work on your system.
  2115.  
  2116. 14.  Define a command so that each user will be able to run ADA-TUTR
  2117. easily.
  2118.  
  2119.  
  2120. We'll be happy to help you install ADA-TUTR and get it running, even
  2121. if you haven't registered or bought a license.  We want you to try
  2122. ADA-TUTR before paying for it.
  2123.  
  2124.                                                                Page 48
  2125.  
  2126.           APPENDIX G:  WE LISTEN!  NEW FEATURES OF ADA-TUTR
  2127.  
  2128. Almost all of the features added to ADA-TUTR were done as a result of
  2129. your comments and suggestions.  Thank you very much, and please
  2130. continue to send them!  We want to produce the very best Ada Tutor
  2131. possible.  Here's a history of revisions to ADA-TUTR.  In addition to
  2132. the changes shown here, we're constantly making minor improvements in
  2133. the tutorial text.
  2134.  
  2135.  
  2136. VERSION 2.01:
  2137.  
  2138. Added the file JANUS.ADA.
  2139.  
  2140. Updated the list of Ada compilers available for the PC (page 39).
  2141.  
  2142.  
  2143. VERSION 2.00:
  2144.  
  2145. Changed the ADA_TUTR.DAT file to a more compact format, so that
  2146. ADA-TUTR would take less room on a hard disk and be able to run from a
  2147. floppy diskette.
  2148.  
  2149. Added the BOOK program to print all of the tutorial screens as a large
  2150. book (page 38).
  2151.  
  2152. Updated Outside Assignment 6 to make it easier to see where the
  2153. 5-second intervals occur.
  2154.  
  2155. Updated the list of Ada compilers available for the PC (page 39).
  2156.  
  2157. Added the sample Multi-User License (pages 40-41).
  2158.  
  2159. Added the special offer for a textbook (page 37).
  2160.  
  2161.  
  2162. VERSION 1.22:
  2163.  
  2164. Added ALTCHAR.C for UNIX based systems that don't have the file
  2165. TERMIO.H.  (Thank you, Mr. Richard Conn, 2700 Bowline Court,
  2166. Maineville, OH 45039.)
  2167.  
  2168.  
  2169. VERSION 1.21:
  2170.  
  2171. Added ONECHAR.C so users of UNIX based systems wouldn't have to strike
  2172. ENTER after each response.  (Thank you, Mr. David Hill, 7549 Wynford
  2173. Street, Salt Lake City, UT 84121.)
  2174.  
  2175. Changed all hyphens in file names to underlines, at the request of
  2176. PC-SIG, so that ADA-TUTR would be compatible with High Sierra Format
  2177. CD-ROMs.
  2178.  
  2179.                                                                Page 49
  2180.  
  2181. VERSION 1.20:
  2182.  
  2183. Added the ability to select background, foreground, and border colors
  2184. on a PC without sacrificing compatibility with mainframe computers and
  2185. monochrome PCs.
  2186.  
  2187. Made ADA-TUTR automatically remember where you leave off when you exit
  2188. the program, so that you don't have to write down the screen number.
  2189. Also made ADA-TUTR remember your color choices.
  2190.  
  2191. Made ADA-TUTR tell you the current screen number and the approximate
  2192. percentage through the course when you strike X, and added the ability
  2193. to go back to the last question or to the last Outside Assignment.
  2194.  
  2195. Added a special screen at the start of each major section, showing an
  2196. outline of the course.
  2197.  
  2198. Updated the tutorial text to reflect the government's new policy
  2199. regarding expiration of Validation Certificates.
  2200.  
  2201. Updated the tutorial text to show that the newest Ada compilers now
  2202. raise CONSTRAINT_ERROR where NUMERIC_ERROR was once raised.
  2203.  
  2204. Added the offer for customized versions of ADA-TUTR, and for the
  2205. Customization Kit (page 4).
  2206.  
  2207. Recompiled ADA-TUTR using a validated compiler from Meridian Software
  2208. Systems, Inc., instead of an older unvalidated compiler from Artek,
  2209. Inc.
  2210.  
  2211. Made ADA-TUTR available on 3.5" as well as 5.25" diskettes.
  2212.  
  2213.  
  2214. VERSION 1.01:
  2215.  
  2216. Fixed minor typographical errors in Version 1.00.
  2217.  
  2218.                                                                Page 50
  2219.  
  2220.                  APPENDIX H:  DISCLAIMER OF WARRANTY
  2221.  
  2222. We hate legal mumbo jumbo, but we have to say the following to protect
  2223. ourselves:
  2224.  
  2225. Software Innovations Technology makes no warranty of any kind,
  2226. expressed or implied, including any warranties of merchantability or
  2227. fitness for a particular purpose.  We shall not be liable for any
  2228. damages, whether direct, indirect, incidental, special, or
  2229. consequential, arising from a failure of this program to operate in a
  2230. manner desired by the user.  We shall not be liable for any damage to
  2231. data or property which may be caused directly or indirectly by use of
  2232. this program.  IN NO EVENT SHALL SOFTWARE INNOVATIONS TECHNOLOGY BE
  2233. LIABLE FOR ANY DAMAGES, INCLUDING ANY LOST PROFITS, LOST SAVINGS, OR
  2234. OTHER INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
  2235. INABILITY TO USE THIS PROGRAM, OR FOR ANY CLAIM BY ANY OTHER PARTY.
  2236.