home *** CD-ROM | disk | FTP | other *** search
/ Chip 1995 March / CHIP3.mdf / programm / prog3 / tabcont.txt < prev    next >
Encoding:
Text File  |  1991-07-01  |  14.0 KB  |  306 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.                       CORONADO ENTERPRISES
  9.  
  10.               ADA TUTORIAL - PART 2 - ADVANCED ADA
  11.  
  12.  
  13.  
  14. This documentation and the accompanying software, including all
  15. of the example Ada programs and text files, are protected under
  16. United States copyright law to protect them from unauthorized
  17. commercialization.  This version of the tutorial is distributed
  18. under the shareware concept, which means you are not required to
  19. pay for it.  You are permitted to copy the disks, and pass copies
  20. on to a friend, provided you do not modify any files or omit any
  21. files from the complete package.  In fact, you are encouraged to
  22. pass complete copies on to friends.  You are permitted to charge
  23. a small fee to cover the costs of duplication, but you are not
  24. permitted to charge anything for the software itself.
  25.  
  26. If you find the tutorial helpful, you are encouraged to register
  27. with the author and to submit a small fee to help compensate him
  28. for his time and expense in writing it.  We will provide you with
  29. a beautifully printed copy of this tutorial if you submit a full
  30. registration.  See the READ.ME2 file on either diskette for addi-
  31. tional details.
  32.  
  33. Whether or not you send a registration fee, feel free to request
  34. a copy of the latest list of available tutorials and a list of
  35. the authorized Public Domain libraries that distribute our full
  36. line of programming language tutorials.
  37.  
  38.  
  39.                  Gordon Dodrill - July 1, 1991
  40.  
  41.  
  42.         Copyright (c) 1988, 1991, Coronado Enterprises
  43.  
  44.  
  45.                      Coronado Enterprises
  46.                     12501 Coronado Ave NE
  47.                 Albuquerque, New Mexico 87122
  48.  
  49.  
  50.               Ada is a registered trademark of
  51.        the U. S. Government (Ada Joint Program Office).
  52.  
  53.                       TABLE OF CONTENTS
  54.  
  55. Part 1 - Beginning Ada
  56.  
  57. Introduction to the Ada tutorial.                    Page I-1
  58.  
  59. Chapter 1 - Getting started.                         Page 1-1
  60.  
  61. Chapter 2 - Program structure.                       Page 2-1
  62.      TRIVIAL.ADA     The minimum Ada program           2-1
  63.      SOMEOUT.ADA     A little output                   2-2
  64.      MOREOUT.ADA     More output                       2-3
  65.      GOODFORM.ADA    Good formatting example           2-4
  66.      UGLYFORM.ADA    Very bad formatting               2-5
  67.      COMMENTS.ADA    Ada comments                      2-5
  68.  
  69. Chapter 3 - The integer type variable.               Page 3-1
  70.      ONEINT.ADA      The INTEGER variable              3-1
  71.      MOREINTS.ADA    More INTEGER variables            3-4
  72.      INITEX.ADA      Integer initialization            3-6
  73.      SUBTYPES.ADA    Ada subtypes                      3-7
  74.      INTATTRS.ADA    Integer attributes                3-11
  75.  
  76. Chapter 4 - Logical compares & precedence.           Page 4-1
  77.      COMPARE.ADA     The BOOLEAN variable              4-1
  78.      COMPARES.ADA    Boolean expressions               4-2
  79.  
  80. Chapter 5 - Control Structures.                      Page 5-1
  81.      LOOPDEMO.ADA    Simple loops                      5-1
  82.      MORELOOP.ADA    More uses of loops                5-3
  83.      IFDEMO.ADA      Conditional statements            5-6
  84.      CASEDEMO.ADA    Another conditional               5-7
  85.      GOTODEMO.ADA    The GOTO statement                5-8
  86.      TEMPCONV.ADA    A useful program                  5-9
  87.      DUMBCONV.ADA    A poorly written program          5-9
  88.  
  89. Chapter 6 - Additional scalar types.                 Page 6-1
  90.      ALLINT.ADA      Integer type variables            6-1
  91.      ENUM.ADA        The enumerated variable           6-3
  92.      BOOLVARS.ADA    The BOOLEAN variable              6-6
  93.      INCRINT.ADA     Integer operations                6-7
  94.      FLOATVAR.ADA    The floating point variable       6-7
  95.      FIXED.ADA       The fixed point variable          6-10
  96.      MIXTYPES.ADA    Simple type conversions           6-11
  97.  
  98. Chapter 7 - Derived types.                           Page 7-1
  99.      DERTYPES.ADA    Derived types                     7-2
  100.      DERSUBS.ADA     Derived subtypes                  7-5
  101.      MOREDERS.ADA    More derived types                7-6
  102.  
  103. Chapter 8 - Subprograms.                             Page 8-1
  104.      PROCED1.ADA     A simple procedure                8-1
  105.      PROCED2.ADA     Several procedures                8-2
  106.      PROCED3.ADA     A procedure with parameters       8-3
  107.      CALLING.ADA     Procedures calling procedures     8-5
  108.      NESTING.ADA     Procedure nesting                 8-5
  109.  
  110. Chapter 8 - Subprograms (continued)                  Page 8-1
  111.      FUNCT.ADA       A simple function                 8-6
  112.      ODDSQRE.ADA     Procedure nesting example         8-7
  113.      OVERLOAD.ADA    Overloading illustration          8-8
  114.  
  115. Chapter 9 - Blocks and scope of variables.           Page 9-1
  116.      SCOPE.ADA       Scope of variables                9-1
  117.      SCOPE2.ADA      Scope of variables                9-2
  118.      BLOCKS.ADA      The ADA block                     9-3
  119.      AUTOMATC.ADA    What are automatic variables?     9-4
  120.  
  121. Chapter 10 - Arrays.                                 Page 10-1
  122.      ARRAY1.ADA      Simple arrays                    10-1
  123.      SLICE.ADA       The Ada slice                    10-4
  124.      MULTARY1.ADA    A multidimensional array         10-5
  125.      MULTARY2.ADA    A multidimensional array         10-6
  126.      MULTARY3.ADA    A multidimensional array         10-6
  127.      ARRYINIT.ADA    Initializing arrays              10-7
  128.  
  129. Chapter 11 - The character & string types.           Page 11-1
  130.      CHARS.ADA       The CHARACTER variable           11-1
  131.      STRING1.ADA     The STRING variable              11-1
  132.      CONCAT.ADA      String concatenation             11-3
  133.      STRNGCMP.ADA    String comparisons               11-3
  134.      CHARINT.ADA     CHAR & INT conversions           11-4
  135.  
  136. Chapter 12 - Records.                                Page 12-1
  137.      RECORD1.ADA     A simple record                  12-1
  138.      RECORD2.ADA     A nested record                  12-3
  139.      RECORD3.ADA     An array in a record             12-4
  140.      RECORD4.ADA     An array of records              12-5
  141.  
  142. Chapter 13 - The access type variable.               Page 13-1
  143.      ACCESS1.ADA     The access variable & INTEGER    13-1
  144.      ACCESS2.ADA     The access variable & FLOAT      13-3
  145.      ACCESS3.ADA     The access variable & records    13-3
  146.      ACCESS4.ADA     The access variable & arrays     13-6
  147.      ACCESS5.ADA     An array of access variables     13-6
  148.  
  149. Chapter 14 - Input/Output.                           Page 14-1
  150.      FORMATS.ADA     Output formatting                14-1
  151.      EASYOUT.ADA     File output                      14-2
  152.      MULTOUT.ADA     Multiple file output             14-3
  153.      CHARIN.ADA      CHARACTER input                  14-4
  154.      STRINGIN.ADA    STRING input                     14-6
  155.      INTIN.ADA       INTEGER input                    14-6
  156.      PRINTOUT.ADA    Using the printer                14-7
  157.  
  158. Chapter 15 - Packages.                               Page 15-1
  159.      ADDERPKG.ADA    A separately compiled package    15-1
  160.      ADDER1.ADA      Using the package ADDERPKG       15-4
  161.      ADDER2.ADA      A package in a definition part   15-6
  162.      ADDER3.ADA      Separate body compilation        15-7
  163.      ADDERSTB.ADA    A body stub                      15-7
  164.      ADDER4.ADA      Initialization section           15-8
  165.  
  166. Chapter 16 - Example Programs.                       Page 16-1
  167.      CHARSTAK.ADA    A simple stack implementation    16-1
  168.      TRYSTAK.ADA     Using the simple stack           16-2
  169.      DYNSTRNG.ADA    A dynamic string package         16-2
  170.      TRYSTRNG.ADA    Using the dynamic string         16-4
  171.      AGE.ADA         How many days old are you?       16-5
  172.  
  173.  
  174. Part 2 - Advanced Ada
  175.  
  176. Chapter 17 - Exceptions.                             Page 17-1
  177.      EXCEPT1.ADA     A simple exception               17-1
  178.      EXCEPT2.ADA     My own simple exception          17-3
  179.      EXCEPT3.ADA     Exception propagation            17-5
  180.      EXCEPT4.ADA     Recovery from an exception       17-6
  181.      EXCEPT5.ADA     Additional exception topics      17-7
  182.  
  183. Chapter 18 - Advanced Subprogram topics.             Page 18-1
  184.      DEFAULTS.ADA    Simple defaults                  18-1
  185.      DEFAULT2.ADA    Variable defaults                18-2
  186.      RECURSON.ADA    Simple recursion                 18-3
  187.      FUNCRECR.ADA    Function recursion               18-4
  188.      REVERS.ADA      Function returning an array      18-6
  189.  
  190. Chapter 19 - Advanced Array topics.                  Page 19-1
  191.      SUMMER.ADA      An unconstrained array           19-1
  192.      ENUMARY.ADA     An enumerated array index        19-2
  193.      ARRAYOPS.ADA    Array operators                  19-3
  194.      ARRAYOP2.ADA    Operator overloading             19-4
  195.      UNARYOP.ADA     Unary operator overloading       19-5
  196.  
  197. Chapter 20 - Advanced record topics.                 Page 20-1
  198.      DISCRIM1.ADA    A simple discriminant            20-1
  199.      DISCRIM2.ADA    Flexible functions               20-2
  200.      DISCRIM3.ADA    A variable discriminant          20-3
  201.      DISCRIM4.ADA    A multiple discriminant          20-4
  202.      VARIANT1.ADA    A variant record                 20-4
  203.      VARIANT2.ADA    A variable variant record        20-6
  204.      INFIX.ADA       Operator overloading             20-7
  205.  
  206. Chapter 21 - Advanced packages & private types       Page 21-1
  207.      NOPRIVAT.ADA    No private type                  21-1
  208.      PRIVAT1.ADA     A private type                   21-2
  209.      PRIVAT2.ADA     A modified private type          21-4
  210.      LIMPRIV.ADA     A limited private type           21-4
  211.  
  212. Chapter 22 - Binary Input/Output                     Page 22-1
  213.      BISEQOUT.ADA    Binary sequential output         22-1
  214.      BISEQIN.ADA     Binary sequential input          22-3
  215.      BIRANDIO.ADA    Binary random input/output       22-4
  216.  
  217. Chapter 23 - Dynamic Allocation.                     Page 23-1
  218.      LINKLIST.ADA    A linked list                    23-1
  219.      SORTLIST.ADA    A sorting linked list            23-4
  220.      BTREE.ADA       A sorting binary tree            23-6
  221.  
  222.  
  223. Chapter 24 - Tasking.                                Page 24-1
  224.      TIMER.ADA       Simple Tasking Example           24-1
  225.      TASK1.ADA       Simple Tasking                   24-4
  226.      TASK2.ADA       Simple Tasking with Delays       24-7
  227.      TASK3.ADA       Tasking in a Code Block          24-7
  228.  
  229. Chapter 25 - The Simple Rendezvous.                  Page 25-1
  230.      HOTDOG.ADA      The Simple Rendezvous            25-1
  231.      HOTDOGS.ADA     Parameter Passing                25-4
  232.      MANYDOGS.ADA    Multiple Callers                 25-5
  233.      RETAIL1.ADA     The Select Statement             25-7
  234.      RETAIL2.ADA     The Guarding Condition           25-8
  235.  
  236. Chapter 26 - The Conditional Rendezvous.             Page 26-1
  237.      MEALS1.ADA      The Select Statement             26-1
  238.      MEALS2.ADA      The Conditional Select           26-2
  239.      MEALS3.ADA      The Delayed Select               26-4
  240.      TERMINAT.ADA    Proper Termination               26-5
  241.  
  242. Chapter 27 - Additional Tasking Topics.              Page 27-1
  243.      TASKTYPE.ADA    The Tasking Type                 27-1
  244.      TASKARRY.ADA    An Array of Tasks                27-3
  245.      TASKACES.ADA    A Task Access Variable           27-3
  246.      PARALLEL.ADA    Parallel Computation             27-4
  247.      PRIORITY.ADA    Tasking Priority                 27-5
  248.      FAMILY.ADA      A Family of Task Entries         27-6
  249.  
  250. Chapter 28 - Generic Subprograms.                    Page 28-1
  251.      SWAPSOME.ADA    A Generic Procedure              28-1
  252.      SWAPMORE.ADA    Generic Subprograms              28-4
  253.      ALLGENER.ADA    Generic Formal Parameters        28-6
  254.      ARRAYGEN.ADA    Array Type Generics              28-7
  255.      ACCESGEN.ADA    Access Type Generics             28-9
  256.  
  257. Chapter 29 - Generic Packages.                       Page 29-1
  258.      GENPKG.ADA      Simple Generic Parameters        29-1
  259.      NESTPKG.ADA     Embedded Generic Packages        29-2
  260.      OBJGEN.ADA      Generic Object Parameters        29-3
  261.      PROCPKG.ADA     Generic Procedure Parameters     29-4
  262.      FUNCPKG.ADA     Generic Function Parameters      29-5
  263.  
  264. Chapter 30 - Control of Representation.              Page 30-1
  265.      SMALLINT.ADA    The Length Specification         30-2
  266.      BITFIELD.ADA    The Record Type Representation   30-4
  267.      PACKITIN.ADA    The PACK Pragma                  30-6
  268.      ENUMREP.ADA     Enumerated Type Representation   30-7
  269.  
  270. Chapter 31 - More Example Programs.                  Page 31-1
  271.      RANDOM.ADA      Random Number Generator          31-1
  272.      TESTRAN.ADA     Test Random Numbers              31-1
  273.      DYNSTRNG.ADA    Dynamic String Package           31-2
  274.      TESTSTRN.ADA    Test Dynamic Strings             31-2
  275.      TRYSTRNG.ADA    Using the dynamic string         31-3
  276.      AGE2.ADA        How old are you?                 31-3
  277.      PHILOS.ADA      Tasking Example                  31-3
  278.      GENSTACK.ADA    Generic Stack                    31-5
  279.      TRYSTAK.ADA     Try Generic Stack                31-5
  280.  
  281.  
  282. Note: Even though this is only Part 2 (Advanced Ada) of the
  283.       Ada tutorial, the entire table of contents is listed for
  284.       the students convenience.
  285.  
  286.  
  287.  
  288.  
  289. ABOUT THE AUTHOR
  290. _________________________________________________________________
  291.  
  292. The author of this tutorial began programming in 1961 using FORTRAN
  293. on an IBM 1620.  Since then, most of his career has been involved
  294. with designing digital logic for satellite applications.  In 1983,
  295. being somewhat burned out with logic design, he began a study of
  296. some of the more modern programming languages and has since made
  297. a complete career shift to software development.  After learning
  298. Pascal, C was studied, followed by Modula-2 and Ada, and more
  299. recently C++.  Rather than simply learning the syntax of each new
  300. language, modern methods of software engineering were studied and
  301. applied to effectively utilize the languages.  He is currently
  302. employed by a large research and development laboratory where he
  303. continues to study, teach, and apply the newer programming
  304. languages.
  305.  
  306.