home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_progs / prog_oth / comal.lzh / COMAL / INFOTEXT / WHATISCOMAL < prev   
Encoding:
Text File  |  1991-08-16  |  8.9 KB  |  245 lines

  1. WHAT IS COMAL?
  2.  
  3. COMAL was designed with the BEGINNER in mind,
  4. including many interactive features. It is tolerant
  5. of mistakes, yet discourages bad habits. This
  6. allows a beginner to develop skills necessary in
  7. advanced structured programming languages, such as,
  8. well, COMAL. The widely acclaimed TURTLE GRAPHICS
  9. are an integral part of COMAL, and have been for
  10. nearly a decade.
  11.  
  12. ADVANCED PROGRAMMERS also pick COMAL as their
  13. language of choice. They utilize the many advanced
  14. and powerful features of COMAL that beginners do
  15. not need to even know about. However, as beginners'
  16. programming skills improve, COMAL always presents
  17. even more power and features for them to use.
  18.  
  19. Let's examine some features that attract beginning
  20. programmers and keep advanced programmers.
  21.  
  22. In direct mode, you interact directly with the
  23. computer. You type in a command and COMAL responds
  24. right away. A beginner usually starts with a PRINT
  25. statement. The PRINT statement tells the computer
  26. to display a message on the screen. This is an
  27. important command. Would you want a program to
  28. calculate your mortgage payment if it couldn't tell
  29. you the answer? In its simplest form, the PRINT
  30. statement can display a text constant. For example,
  31. type:
  32.  
  33.   PRINT "hello"
  34.  
  35. and COMAL responds with:
  36.  
  37.   hello
  38.  
  39. COMAL is also good with calculations. When you
  40. balance your checkbook, COMAL can help. If your
  41. starting balance is $313.76 and you wrote two
  42. checks ($250.00 and $125.98) type:
  43.  
  44.   PRINT 313.76-250.00-125.98
  45.  
  46. COMAL immediately responds with:
  47.  
  48.   -62.22
  49.  
  50. No wonder that check bounced. Actually, a useful
  51. program is usually harder than this. But don't
  52. worry, COMAL helps you in many ways.
  53.  
  54. COMAL provides a full screen editor to help you
  55. write programs. You don't have to load a special
  56. program to use this editor. Just type in the
  57. program lines from direct mode as described above.
  58. A program line consists of a line number followed
  59. by a statement. With its AUTO command, COMAL can
  60. provide the line number for you. You just type in
  61. the statement.
  62.  
  63. COMAL's editor doesn't sit around watching you type
  64. either. It tries to figure out what you are telling
  65. it. If it doesn't understand, it will tell you
  66. right when you enter the line! Often it offers
  67. advice on how to fix mistakes. This is when you
  68. will like COMAL's insert, delete, and cursor
  69. features. You don't retype the entire line, just
  70. the corrections.
  71.  
  72. I can hear you saying, "Ok, COMAL is friendly, but
  73. what can it really do?" The power of COMAL comes
  74. from its commands, file handling ability, and
  75. program structures.
  76.  
  77. You have already seen the PRINT command. COMAL
  78. provides several commands to deal with numeric and
  79. text data. The data can be provided to a running
  80. program from DATA statements in the program, from
  81. a file stored on disk, or by the person using the
  82. program. COMAL supports all the usual math
  83. operators such as addition, subtraction,
  84. multiplication, and division. It also knows
  85. logarithms, trig functions, two methods for
  86. generating random numbers, and a lot more. Text
  87. strings may be added together or have sub-strings
  88. extracted from them. A built-in string search even
  89. tells the position of one string within another if
  90. there is a match. Comparison operators allow
  91. strings and numbers to be sorted. Numbers can be
  92. converted to text format and back again.
  93.  
  94. COMAL supports two kinds of data files. SEQUENTIAL
  95. files read data from start to finish. You can write
  96. to sequential files or read from them, but not both
  97. at the same time. RANDOM ACCESS files are good if
  98. you store lots of records together, but only access
  99. a few at a time. You can read any record, update
  100. the information, and write it back. You don't have
  101. to start at the beginning of the file.
  102.  
  103. Normally, COMAL uses the screen for all its output.
  104. But a special option redirects PRINT statements to
  105. your printer or even a disk file. You SELECT the
  106. output location. Later, you SELECT the screen
  107. again.
  108.  
  109. Easy so far! But it is COMAL's structures that
  110. simplify programming and keep advanced users from
  111. switching to another language. COMAL has four loop
  112. structures, two conditional branching structures,
  113. named procedures and functions with parameters, and
  114. an error trapping structure. They are discussed in
  115. the STRUCTURES article. AmigaCOMAL and the newest
  116. IBM PC COMAL 3.0 also include a powerful RECORD
  117. structure and POINTERs.
  118.  
  119. The loop structures execute one or more consecutive
  120. statements over and over. Most loops have a
  121. one-line short form.
  122.  
  123. The REPEAT and WHILE loops are similar. Both loop
  124. an indefinite number of times. The difference is
  125. when they decide to stop. The REPEAT loop places
  126. its test at the end of the loop. Thus the
  127. statements inside the loop will always be executed
  128. at least once. The WHILE loop places the test at
  129. the start, so it is possible to skip the statements
  130. inside altogether.
  131.  
  132. COMAL also includes the FOR loop. It counts from a
  133. starting value to the terminating value. This not
  134. only lets you specify the exact number of times the
  135. loop should execute, but also gives you a counter
  136. to use for other things.
  137.  
  138. The last loop structure is LOOP. Like REPEAT and
  139. WHILE loops, the statements inside are executed an
  140. indefinite number of times. However, it's EXIT is
  141. from the middle, not the ends, and you can specify
  142. exactly how many loops to take as an option.
  143.  
  144. The conditional structures choose one section of
  145. code over another based on a comparison. A multi-
  146. line IF structure has its primary test on the first
  147. line (optional ELIF secondary tests are also
  148. allowed). If the test is true, its statements are
  149. executed. Otherwise, an ELSE section is executed
  150. (if you include it). A one-line IF is also
  151. available.
  152.  
  153. The CASE structure evaluates one expression at the
  154. start (either a number or a text string). The value
  155. is compared to the values in the WHEN statements.
  156. If the main expression value matches a value in a
  157. WHEN statement, the section of code below that WHEN
  158. statement is executed. If there is no match, the
  159. section of code below the optional OTHERWISE
  160. statement is executed.
  161.  
  162. COMAL automatically indents lines within structures
  163. for you! It also capitalizes keywords and puts
  164. variable names in lower case. This makes it easy to
  165. follow the program.
  166.  
  167. COMAL also allows you to store program segments on
  168. disk. You recall them into future programs using
  169. the MERGE command. Lines are renumbered
  170. automatically to fit the new program.
  171.  
  172. COMAL is a powerful language. However, no language
  173. can include everything. That's why COMAL includes
  174. the possibility to extend itself. You can write
  175. long routines, give them names, and call them with
  176. a single command, just like a PRINT statement.
  177. These routines can be called from direct mode or a
  178. running program. These are procedures and
  179. functions.
  180.  
  181. A procedure is usually a set of statements that
  182. work well together. Information can be transferred
  183. to and from procedures through variables called
  184. parameters.
  185.  
  186. Functions are like procedures -- multi-line
  187. structures which can have parameters and are called
  188. with a single statement. The difference is that
  189. unlike a procedure, a function also returns a value
  190. (string or numeric) to the statement which called
  191. it.
  192.  
  193. Don't overlook COMAL's error handling structure. A
  194. language which permits interaction with a user
  195. should anticipate the possibility for errors which
  196. are difficult to resolve. A classic example is
  197. division by zero. Many languages give you two
  198. choices: test every expression before it has a
  199. chance to cause an error, or let the system crash.
  200. The first method has two drawbacks: it slows
  201. program execution and the test itself may cause a
  202. crash.
  203.  
  204. COMAL gives you a third choice - utilize its Error
  205. Handler! This structure can be used to minimize the
  206. effects of errors. The Handler can't create the
  207. data in a missing file in the case of a FILE NOT
  208. FOUND error, but it can give you a second chance to
  209. put the correct disk in the disk drive. Since the
  210. Error Handler is a true structure it is easy to
  211. use. Advanced programmers can utilize it fully,
  212. complete with nested Error Handlers.
  213.  
  214. Finally COMAL can be extended and expanded
  215. indefinitely with packages. Beginners can use
  216. packages without knowing how they are created.
  217. Advanced programmers will find packages an exciting
  218. way to tailor the COMAL system to their needs. Now
  219. even beginners can try their hand at writing
  220. packages since AmigaCOMAL allows you to write a
  221. package in COMAL (or in Assembler or C).
  222.  
  223. The above description is not a complete review of
  224. COMAL, but should give you an idea of what to
  225. expect. All COMAL 2.0 implementations are
  226. compatible and include these features. Plus each
  227. adds its own special characteristics (such as
  228. mouse, windows and speech in AmigaCOMAL). Trace
  229. commands are often included to help follow program
  230. flow. Some of these enhancements are mentioned in
  231. the separate reviews of the different
  232. implementations.
  233.  
  234. We can provide user groups with multiple copies of
  235. these information files as a booklet for
  236. distribution at meetings.
  237.  
  238. For a free copy of the 24 page COMAL INFO booklet
  239. send a Self Addressed Stamped (45 cents) Envelope
  240. to:
  241.  
  242.     COMAL Users Group USA Ltd
  243.     5501 Groveland Terrace
  244.     Madison, WI 53716
  245.