home *** CD-ROM | disk | FTP | other *** search
/ AMIGA PD 1 / AMIGA-PD-1.iso / Programme_zum_Heft / Programmieren / Kurztests / ACE / archive / ACE23.LHA / MAIN.lha / utils / a-a / a-a.doc < prev   
Text File  |  1994-10-22  |  12KB  |  256 lines

  1. From XRACTON@FULLERTON.EDU Thu Jun 24 00:39:05 1993
  2. Return-Path: <XRACTON@FULLERTON.EDU>
  3. Received: from csu.Fullerton.EDU by leven.appcomp.utas.edu.au (4.1/SMI-4.1)
  4.     id AB05310; Thu, 24 Jun 93 00:38:13 EST
  5. Received: from FULLERTON.EDU by FULLERTON.EDU (PMDF #2446 ) id
  6.  <01GZPKDRJYSS002QFT@FULLERTON.EDU>; Wed, 23 Jun 1993 07:36:24 PST
  7. Date: 23 Jun 1993 07:36:23 -0800 (PST)
  8. From: ROLAND ACTON <XRACTON@FULLERTON.EDU>
  9. Subject: A-A documentation
  10. To: dbenn@leven.appcomp.utas.edu.au
  11. Message-Id: <01GZPKDRJYSU002QFT@FULLERTON.EDU>
  12. X-Vms-To: IN%"dbenn@leven.appcomp.utas.edu.au"
  13. Mime-Version: 1.0
  14. Content-Transfer-Encoding: 7BIT
  15. Status: OR
  16.  
  17.                             AMOS to ACE
  18.                             Version 1.0
  19.                            June 22, 1993
  20.  
  21. INTRODUCTION
  22. ------------
  23.   This program is intended for people like me: people who have a
  24. big, bulky application program written in AMOS BASIC. AMOS is nice
  25. for development, because it's interpreted, and runs fast. But
  26. programs written in it have a lot of problems - such as opening up
  27. their own screen (which is not Intuition-compatible), not
  28. multitasking with each other, and not working properly with the
  29. 68040. This makes AMOS programs murder to run for any serious
  30. computer user - and most of them won't.
  31.   ACE has its own set of problems, but most of them are compiler
  32. limitations. They're not things that would affect the end user of
  33. the application program. When you're writing programs for fame,
  34. instead of fortune, that's an important consideration.
  35.   AMOS and ACE are not completely compatible. Most of the commands
  36. found in ACE are in AMOS, but some of them have the parameters in a
  37. different order. There are a few cases where both programs have the
  38. same function, but require a different command to execute it. This
  39. can make converting from one to the other rather tedious - and once
  40. you do, you have to either drop the original version, or (try) to
  41. develop them both in parallel.
  42.   AMOS to ACE is designed to help. With it, you can keep one version
  43. of your program (in AMOS format) and convert it to ACE when you're
  44. ready to compile it. It has quite a few limitations, and can't
  45. convert anywhere near all of AMOS's command set (most of them have
  46. no analogues in ACE), but should be very useful to serious
  47. developers (who don't want to admit that they're writing programs in
  48. AMOS). The program is user-extensible, and enough information is
  49. provided in this documentation to allow interested users to
  50. customize the program.
  51.  
  52. SUPPORTED CONVERSIONS
  53. ---------------------
  54. X, Y, A$, B$, ect. represent the positions of variables in commands.
  55.  
  56. AMOS VERSION                            ACE VERSION
  57. Inc X                                   ++X
  58. Dec X                                   --X
  59. Add X,Y-Z                               X=X+Y-Z
  60. Free                                    FRE(-1)
  61. Instr(A$,B$,X)                          INSTR(X,A$,B$)
  62. Upper$(A$)                              UCASE$(A$)
  63. End If                                  END IF
  64. If(X=Y)                                 IF (X=Y) THEN
  65. Do                                      REPEAT
  66. Loop                                    UNTIL 1=0
  67. Rnd(X)                                  RND
  68. Fix(A)                                  FIX A+1
  69. Say "hello",1                           SAY "hello"
  70. Open Out 1,"out_file"                   OPEN "O",#1,"out_file"
  71. Open In 1,"junk_file"                   OPEN "I",#1,"junk_file"
  72. Append 1,"my_foo_bar"                   OPEN "A",#1,"my_foo_bar"
  73. Hex$(X,Y)                               HEX$(X)
  74. Bin$(X,Y)                               BIN$(X)
  75. Deek(A)                                 PEEKW(A)
  76. Doke A,Y                                POKEW A,Y
  77. Leek(A)                                 PEEKL(A)
  78. Loke A,Y                                POKEL A,Y
  79. Procedure HELLO[X,Y,Z]                  SUB HELLO(X,Y,Z)
  80. Procedure HELLO                         SUB HELLO
  81. End Proc                                END SUB
  82. Proc HELLO[X,Y,Z]                       CALL HELLO(X,Y,Z)
  83. Proc HELLO                              CALL HELLO
  84. Set Buffer 100                          <blank line>
  85. String$(A$,X)                           STRING$(X,A$)
  86. Rename "hello" To "goodbye"             NAME "hello" AS "goodbye"
  87. Lower$(A$)                              LCASE$(A$)
  88.  
  89.   Note that the LCASE$ function is not part of ACE's command set. It
  90. is found in <strings.h> and must be included.
  91.   Although a version of the MID$ command, with different syntax, is
  92. also in <strings.h>, A-A does not convert to it from AMOS. AMOS's
  93. version of the MID$ command has a serious bug, and should never be
  94. used. (Note that AMOS's MID$ FUNCTION works properly)
  95.   I've been told that in a recent version of AMOS Pro the MID$
  96. command bug has finally been found and corrected, but in all prior
  97. versions (and in all versions of the original AMOS) the bug still
  98. exists.
  99.  
  100. HOW IT WORKS
  101. ------------
  102.   A-A works by comparing each program line against several dozen
  103. internal templates. If a match is found, the "corrected" version of
  104. the match is output. If not, the first character of the line is
  105. deleted from the internal buffer and output to the destination file,
  106. and the process begins again. A typical template looks like this:
  107.  
  108. CONVANYFROM$(11)="Rnd(\1)"+Chr$(10)
  109.  
  110.   The "R", "n", "d" and left parenthesis characters are "constants" -
  111. if they don't match with the input line, the comparison immediately
  112. fails. The backslash is special - it is the "variable" character.
  113. A-A has nine internal "variables" which it uses to rearrange parts
  114. of the input line. The backslash must be followed immediately by the
  115. variable number, and then by the "success-character" and the
  116. "failure-character". When A-A sees the backslash, it scans through
  117. the input line, looking for both the success and failure characters.
  118. If the failure-character appears before the success-character, or
  119. the success-character does not appear at all, the match fails.
  120.   Otherwise, the input line, up to the point that the
  121. success-character was found, is placed in the specified "variable",
  122. and A-A continues comparing the template against the input line,
  123. starting from the position right after where the success-character
  124. was found. Notice that the success-character in the example is a
  125. right parenthesis, and the failure-character is a linefeed (the
  126. Amiga's end-of-line character).
  127.   If any match fails, all variables are cleared before the input
  128. line is compared against the next template. Also, if the same
  129. variable appears multiple times in a template, the appropriate
  130. section of the input line is added onto the existing contents of the
  131. variable.
  132.   If a template matches completely, a definition such as this is
  133. used to determine what to output:
  134.  
  135. CONVANYTO$(11)="RND"
  136.  
  137.   All characters specified, except for the backslash character, are
  138. output verbatim. Again, the backslash character is special - it is
  139. followed immediately by a variable number, and the contents of that
  140. variable are inserted into that position in the output. In the
  141. example, the contents of the variable have been discarded - ACE's
  142. version of the Random function does not take a parameter.
  143.   There are two kinds of templates in A-A.  The ones in the arrays
  144. beginning with CONVBEGIN are checked against the input line only
  145. once, starting with the first character. This is because certain
  146. commands (such as IF) can only legally appear at the beginning of
  147. the line, and so it is not necessary to check for them across the
  148. entire line. Commands in the arrays beginning with CONVANY (such as
  149. the Instr function) can appear at any place in the input line, and
  150. so are checked for at every position.
  151.   The template conversion method has some problems. The worst of
  152. them appears in connection with strings. If A-A sees the input line
  153.  
  154. PRINT "Let Freedom Ring"
  155.  
  156. it will erroneously convert the Free in Freedom to FRE(-1).
  157.   Another problem occurs because of AMOS's IF statements. There are
  158. actually two versions of the IF statement in AMOS - one that has a
  159. "then" and one that does not. The scope of the "then" version is
  160. limited to the current line; the other version must be terminated
  161. with an END IF. A-A will always add a THEN onto the end of an IF;
  162. this will cause ACE to generate an error if there was already a THEN
  163. there. Fortunately, though, AMOS has an odd restriction about the
  164. "then" version - it can't be used if you're already inside an IF (of
  165. either kind). Thus I never use the "then" version, because I would
  166. have to rewrite it if I ever put another IF around that block of
  167. code. Hopefully, most other AMOS users think the same way.
  168.   A third problem occurs because the conversion routines are not
  169. recursive. If A-A converts an IF statement, it will not convert the
  170. statement's parameters.
  171.   A-A does have one "special case" patch - if the success-character
  172. in a variable is a right parenthesis, A-A will keep track of the
  173. number of left and right parentheses it encounters in the input
  174. line, and not match with any nested right parentheses.
  175.   These problems, and others, can be solved (with some annoyance) by
  176. using the conditional conversion feature.
  177.  
  178. CONDITIONAL CONVERSION
  179. ----------------------
  180.   Sections of code can be designated as AMOS-only or ACE-only. This
  181. is done in the following way:
  182.  
  183. Rem Begin AMOS
  184.       ...
  185. <AMOS-only code>
  186.       ...
  187. Rem End AMOS
  188.  
  189. Rem ACE      ...
  190. Rem ACE <ACE-only code>
  191. Rem ACE      ...
  192.  
  193.   Note that these Rem statements must be typed EXACTLY as shown.
  194.   When A-A sees the text "Rem Begin AMOS", it will discard all lines
  195. after that until it sees the text "Rem End AMOS". It will then place
  196. "Rem AMOS" into the output stream to mark the place (in case you
  197. want to look at the output file) and continue as normal.
  198.   When A-A sees the text "Rem ACE", it will strip it out and place
  199. the remainder of the line into the output stream, without performing
  200. any conversions. It will then continue as normal.
  201.   Although this feature was mainly intended to allow you to replace
  202. AMOS commands (particularly graphic-oriented ones) with ones that
  203. will work under ACE, it can also be used to get around the template
  204. converter's limitations. Make a copy of the "problem" line, manually
  205. do whatever conversions are necessary, and designate the old and new
  206. lines as AMOS- and ACE-only, respectively.
  207.   Making use of this feature will affect the size of your source
  208. code and (marginally) the speed of your interpreted program. It will
  209. not affect the final compile, because only the ACE sections will get
  210. to the compiler.
  211.  
  212. VARIABLE TYPE DIFFERENCES
  213. -------------------------
  214.   AMOS has two kinds of numeric variables: integers (4 bytes) which
  215. do not have a qualifier, and floating-point variables (4 bytes),
  216. which have a "#" as a qualifier. ACE has four kinds: short integer
  217. (2 bytes, "%" qualifier), long integer (4 bytes, "&"),
  218. single-precision (4 bytes, "!"), and double-precision (8 bytes,
  219. "#").
  220.   In AMOS, if no qualifier is appended to a variable name, it is
  221. treated as an integer. In ACE it's treated as single-precision.
  222. This isn't a problem because A-A automatically puts a DEFLNG a-z
  223. directive at the beginning of the output file, which makes all
  224. integers the same length as AMOS.
  225.   The difference is with the floating-point variables. In AMOS, a
  226. 4-byte float has a trailing hash character; in ACE it has a trailing
  227. exclamation point. The easiest course is simply to leave the
  228. variable alone; ACE will just see it as a variable of greater
  229. precision than it originally was. This should cause no problems (I
  230. hope).
  231.   At the moment, double-precision variables aren't implemented in
  232. ACE - they're treated by the compiler as single-precision. So, for
  233. now, there is no potential incompatibility problem.
  234.  
  235. OTHER STUFF
  236. -----------
  237.   There are two extra subroutines in A-A called BEFORECHECK and
  238. AFTERCHECK. These are called on each character "step" through the
  239. input line, before and after (respectively) the line is compared
  240. against the templates. At the moment, BEFORECHECK is being used only
  241. to implement the conditional conversion feature, and AFTERCHECK is
  242. blank. You can place extra code in the subroutines to make A-A
  243. handle your specific personal requirements.
  244.  
  245.  
  246.  
  247. Interested parties can contact me at:
  248.  
  249. Roland Acton
  250. 8001 Bluebird Lane
  251. La Palma, CA, 90623
  252. U.S.A.
  253.  
  254. Internet: xracton@ccvax.fullerton.edu
  255.  
  256.