home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 5 / FreshFish_July-August1994.bin / bbs / dev / ace-ag-docs.lha / ACE-AG-Docs / ACE.Guide < prev    next >
Encoding:
Text File  |  1994-03-26  |  92.8 KB  |  2,390 lines

  1. @ DATABASE "ACE.doc"
  2. @ MASTER "ACE.GUIDE"
  3.  
  4. @NODE MAIN "ACE"
  5.                    --------
  6.                  ACE v2.0
  7.                  --------
  8.  
  9.  
  10.  
  11.  
  12.                       @{" Inroduction                  " link 1introduction}
  13.                       @{" Getting started              " link 2started}
  14.                       @{" A hitch-hiker's guide to ACE " link 3hitch-hiker}
  15.                       @{" Stop bits                    " link 4stop}
  16. @ENDNODE
  17.  
  18. @NODE 1introduction "Introduction"
  19.                                Introduction
  20.                                ------------
  21.  
  22.  
  23.  
  24.                              @{" What is ACE?   " link 1what}
  25.                              @{" Who is it for? " link 1who}
  26. @ENDNODE
  27.  
  28. @NODE 2started "Getting started"
  29.                                Getting started
  30.                                ---------------
  31.  
  32.  
  33.                         @{" Installation               " link 2installation}
  34.                         @{" Using the compiler         " link 2using}
  35.                         @{" Compiler options           " link 2options}
  36.                         @{" Running ACE programs       " link 2running}
  37.                         @{" About the example programs " link 2example}
  38. @ENDNODE
  39.  
  40. @NODE 3hitch-hiker "A hitch-hiker's guide to ACE"
  41.                         A hitch-hiker's guide to ACE 
  42.                         ----------------------------
  43.  
  44.  
  45.  @{" General comments                   " link 3comments}     @{" Machine code calls              " link 3machine}
  46.  @{" The preprocessor & #include files  " link 3preproc}     @{" External references             " link 3ref}
  47.  @{" Data types, expressions, constants " link 3data}     @{" Windows                         " link 3windows}
  48.  @{" Precedence of operators            " link 3ops}     @{" Screens                         " link 3screens}
  49.  @{" Identifiers                        " link 3id}     @{" Gadgets                         " link 3gadgets}
  50.  @{" Indirection operators              " link 3indirect}     @{" Menus                           " link 3menus}
  51.  @{" Files                              " link 3files}     @{" Requesters                      " link 3requesters}
  52.  @{" Command line & Workbench arguments " link 3clwb}     @{" Turtle Graphics                 " link 3turtle}
  53.  @{" Subprograms                        " link 3subs}     @{" Sound                           " link 3sound}
  54.  @{" Structures                         " link 3struct}     @{" Event trapping                  " link 3event}
  55.  @{" Shared library function calls      " link 3lib}     @{" Error handling                  " link 3error}
  56. @ENDNODE
  57.  
  58. @NODE 4stop "Stop bits"
  59.                                  Stop bits
  60.                                  ---------
  61.  
  62.  
  63.                   @{" Notes for assembly programmers       " link 4asm}
  64.                   @{" Limitations                          " link 4limit}
  65.                   @{" Known bugs                           " link 4bugs}
  66.                   @{" Future versions                      " link 4future}
  67.                   @{" A note to PD libraries and reviewers " link 4pd}
  68.                   @{" Disclaimer                           " link 4disclaim}
  69.                   @{" References                           " link 4refer}
  70.                   @{" Final word                           " link 4final}
  71. @ENDNODE
  72.  
  73. @NODE 1what "What is ACE" 
  74.  
  75. What is ACE?
  76. ------------
  77.  AmigaBASIC Compiler with Extras?
  78.  A Creative Environment? 
  79.  A Compiler for Everyone?
  80.  A Cool Enterprise?
  81.  Automatic Computing Engine (ala Alan Turing)?
  82.  Dr Who's last companion?  
  83.  
  84. Okay, seriously...
  85.  
  86. ACE is a freely distributable, recursive descent, peephole-optimising
  87. Amiga BASIC compiler which produces A68K-compatible assembly source code.
  88.  
  89. ACE runs under Wb 1.3, 2.x and up, as do the executables it produces. ACE
  90. will run in 512K, but more than this is required for programs beyond about
  91. 250 lines.
  92.  
  93. ACE supports a large subset of AmigaBASIC. It also provides a variety of 
  94. commands, functions and features not found in AmigaBASIC.
  95.  
  96. In most cases, ACE programs produce results which are similar or identical 
  97. to programs written in AmigaBASIC.
  98.  
  99. Any differences between the two are discussed in this document and the 
  100. command and function reference.
  101.  
  102. The following files constitute a complete ACE package:
  103.  
  104.         executables
  105.         -----------      
  106.     bas        - A shell script which automates
  107.                 the production of ACE executables.
  108.     app        - A simple preprocessor.
  109.     ace        - The BASIC compiler.
  110.     a68k        - Charlie Gibbs' 68000 assembler.
  111.     blink        - The Software Distillery's linker.
  112.     muchmore    - The file viewer by Fridtjof Siebert 
  113.               (version which works under Wb 1.3).
  114.  
  115.      documents
  116.     ---------        
  117.     Ace.Guide    - The document you are reading which describes ACE.
  118.     Ref.Guide     - A command and function reference for ACE.
  119.     history        - A history of ACE's development.
  120.     a68k.doc    - Documentation for the assembler.
  121.     blink.doc    - Documentation for the linker.
  122.  
  123.     scanned libraries
  124.     -----------------
  125.     ami.lib        - A freely distributable version of amiga.lib.
  126.     startup.lib    - A library of routines needed at the start and
  127.               end of an ACE program run.
  128.     db.lib        - A library of assorted routines used by ACE
  129.               programs.
  130.  
  131.     other stuff
  132.     -----------
  133.     includes    - Some useful ACE include files. 
  134.     icons        - ACE tool and document icons.
  135.     utils        - Miscellaneous utilities.
  136.     examples    - Example programs which demonstrate many of ACE's 
  137.               capabilities.
  138.      AIDE        - A simple graphical front-end for ACE with "make"
  139.               capabilities.
  140.  
  141. With one exception (see the discussion of file requesters under Wb 1.3 in 
  142. the "@{"Requesters" link 3requesters}" section below) ACE programs do not require any special
  143. run-time shared libraries, so the executables which the compiler produces 
  144. (via the assembler and linker) are completely portable, requiring only the 
  145. standard Amiga shared libraries in your LIBS: directory. The three ".lib" 
  146. files mentioned above are scanned libraries and code from these is
  147. included at link time.
  148.  
  149. ACE is written in C (Sozobon's ZC v1.01), while db.lib and startup.lib are 
  150. written in assembler (~60%) and C.
  151.  
  152. A68K and Blink are used to assemble and link the code produced by ACE.
  153. The MicroEmacs (v1.3 & v2.1) editor has been used throughout every stage
  154. of ACE's development. It works for me.
  155.  
  156. The complete ACE package may be freely distributed.
  157. @ENDNODE
  158.  
  159. @NODE 1who "Who is it for?" 
  160.  
  161. Who is it for?
  162. --------------
  163. ACE is intended for anyone who already knows BASIC and wants one or more of
  164. the following:
  165.  
  166.     - Faster program execution.
  167.  
  168.     - Independence from the BASIC interpreter, ie: standalone 
  169.       programs which are runnable from the CLI/Shell and Workbench.
  170.  
  171.     - Extra commands, functions and features: turtle graphics,
  172.       command-line (and Workbench) arguments, recursion, SUBs with 
  173.       return values, external references, named constants, structures, 
  174.       include files, better @{"WAVE" alink ace:docs/ref.guide/wave} command, gadgets, requesters, etc.
  175.  
  176. Maybe you don't wish to learn another high-level language, or perhaps you 
  177. already use C or assembler but prefer to use BASIC for some tasks while 
  178. still having the power of a compiled language.
  179.  
  180. ACE is a general purpose language so in theory at least, it can be applied
  181. to any programming task you like. In practice however, I find ACE to be
  182. most useful for writing small to medium sized programs where speed is
  183. important but so is ease of programming.
  184.  
  185. ACE is also a useful prototyping language. It allows you to get something 
  186. up and running quickly to test an idea. You may later decide to re-code in 
  187. C or assembler, or you may just add some polish to the existing ACE
  188. program.
  189.  
  190. The latter is becoming more feasible as ACE matures.
  191.  
  192. I have written the following kinds of programs with ACE:
  193.  
  194.     - Shell utilities, eg: basic calculator (ACE:prgs/ShellUtils/bc.b).
  195.     - Fractal/Chaos programs.
  196.     - Neural networks.
  197.     - An 8SVX sound sample player.
  198.     - Astronomy programs, eg: galaxy collision simulator,
  199.       Jovian satellite motion simulator, Messier object database.
  200.     - An Integrated Development Environment (@{"AIDE" alink ace:docs/aide.guide/main} - see separate
  201.       archive).        
  202.     - A program which matches section headings to line and page 
  203.       numbers to create the document you are now reading from an
  204.       unformatted version of it.
  205. @ENDNODE 
  206.  
  207. @NODE 2installation "Installation"
  208.  
  209. Installation
  210. ------------
  211. You will need to open a shell to install ACE. Installation consists of:
  212.  
  213.     - Extracting the four archives found in the single supplied ACE 
  214.       archive.
  215.  
  216.     - Adding a few commands to your s:user-startup (Wb 2.x/3.0) or 
  217.       s:startup-sequence (Wb 1.3) file.
  218.  
  219. The ACE distribution archive contains:
  220.  
  221.     - MAIN.lha        (main ACE files with a few examples)
  222.     - DOCS.lha        (documentation for ACE,A68K and Blink)
  223.     - PRGS.lha        (more example programs)
  224.     - AIDE.lha        (a graphical front-end for ACE)
  225.  
  226. All four will fit onto a single floppy disk in their compressed form.
  227.  
  228. You must now extract the files from each archive with:
  229.  
  230.     lha x <archive>
  231.  
  232. If you have a hard disk, just extract all four archives into a directory
  233. created for ACE (eg: sys:ACE). Extract MAIN.lha first. This will set up
  234. the directory structure and main ACE files.
  235.  
  236. The extraction of MAIN.lha also creates three subdirectories for the last 
  237. three archives. So, finally, extract DOCS.lha, PRGS.lha and AIDE.lha into
  238. the docs, prgs and AIDE subdirectories.
  239.  
  240. If you are using a floppy-only system, extract MAIN.lha onto one disk and 
  241. the last three archives onto other disks to suit yourself. The disk on
  242. which the main ACE files reside is the volume to which the shell commands
  243. discussed below refer.
  244.  
  245. You now have all the files you require to use ACE.
  246.  
  247. Next, add the following lines to your user-startup or startup-sequence 
  248. script:
  249.  
  250.     assign ACE: <volume or directory>
  251.     path ACE:bin add
  252.  
  253. where <volume or directory> is the name of the disk or directory where
  254. the main ACE files now reside (eg: assign ACE: sys:ACE).
  255.  
  256. In addition, you need to add three more statements to your startup-sequence
  257. or user-startup script:
  258.  
  259.     assign ACElib:       ACE:lib    ; bas finds scanned libraries here.
  260.     assign ACEbmaps:   ACE:bmaps    ; ace looks here for .bmap files.
  261.     assign ACEinclude: ACE:include    ; app uses this for include files.
  262.  
  263. You may also have to set the "s" bit on ACE:bin/bas if it was lost during
  264. the unarchiving process. Do this with the following command:
  265.  
  266.     protect ACE:bin/bas +s add
  267.  
  268. If you're not sure, do it anyway. This simply lets you run the bas script
  269. without having to use the "execute" command.
  270.  
  271. Now reboot your Amiga to let the above path and assign commands take
  272. effect.
  273.  
  274. That's it!
  275.  
  276. ** Note: As an alternative to these startup script modifications, you can 
  277. use the "ACEsetup" script to be found in MAIN.lha. Read the comments at 
  278. the top of that script for usage details.
  279. @ENDNODE
  280.  
  281. @NODE 2using "Using the compiler" 
  282.  
  283. Using the compiler
  284. ------------------
  285. Starting with ACE v2.0 there are two ways to use the compiler:
  286.  
  287.     - From the shell/CLI.
  288.  
  289.     - Via an Integrated Development Environment: AIDE.
  290.  
  291. Whichever environment you choose to work with ACE in, read on.
  292.  
  293. ACE expects all BASIC source files to have a ".b" extension.
  294.  
  295. If you have a program called foo.b, you would invoke the compiler thus:
  296.  
  297.     ace foo    (or ace foo.b)
  298.  
  299. This would produce foo.s, an A68K-compatible assembly source (text) file.
  300.  
  301. If you wanted to preprocess, compile, assemble and link foo.b, you'd type:
  302.  
  303.     bas foo
  304.  
  305. which would yield foo (the executable).
  306.  
  307. The bas script sets the stack to 40000 bytes. Before running ACE by itself,
  308. you will need to set this. A minimum stack size seems to be around 5000
  309. for many ACE compilations, but I recommend 40000 to be safe.
  310.  
  311. If your Amiga GURUs or hangs during a compile or produces garbage in the 
  312. shell, you can be confident that the stack is too small.
  313.  
  314. You can either create a BASIC source file using an editor or in the
  315. AmigaBASIC environment. If you want to compile a program developed with
  316. the interpreter, just save the program in ASCII format thus:
  317.  
  318.     save "foo.b",a
  319.  
  320. ACE will only compile ASCII source files, not AmigaBASIC's compressed
  321. format.
  322.  
  323. For those who don't have access to the AmigaBASIC interpreter but who
  324. wish to convert old AmigaBASIC programs not saved in ASCII format, see
  325. the ACE:utils directory for a utility called ab2ascii written by Stefan
  326. Reisner.
  327. @ENDNODE
  328.  
  329. @NODE 2options "Compiler options" 
  330.  
  331. Compiler options
  332. ----------------
  333. The full command line syntax for ACE is:
  334.  
  335.     ace [-bcEilOw] <sourcefile>[.b]
  336.  
  337. which indicates that there are currently seven optional compiler switches. 
  338.  
  339. The switches can appear in any combination (eg: -bO, -clb, -O, -ObE) but 
  340. *are* case sensitive (so -b does not equal -B).
  341.  
  342. The "b" switch tells the compiler to include code to check for ctrl-c
  343. breaks by the user. The inclusion of this code can result in noticeably
  344. larger assembly source files, but execution speed doesn't seem to suffer
  345. appreciably.
  346.  
  347. When a ctrl-c is detected, the program will clean up and exit but
  348. user-defined windows and screens will remain open. The use of ON BREAK
  349. can get around this by allowing for user-controlled clean up
  350. (see the "@{"Event Trapping" link 3event}" section below).
  351.  
  352. The "c" switch includes each line of ACE source code as a comment in the
  353. final assembly source file. This was requested as a debugging aid. Warning:
  354. the presence of such comments interferes with peephole optimisation. Also
  355. be aware that ACE sometimes includes extra code apart from that which you
  356. would expect purely on the basis of the source code.
  357.  
  358. The "E" switch creates a file in the current directory called ace.err which
  359. contains all error messages generated during a compliation. Error messages
  360. are still displayed to the screen during compilation however.
  361.  
  362. The "i" switch tells ACE to make an icon for the executable resulting from 
  363. the compilation. The file "ACE:icons/exe.info" must exist as it is used as
  364. the source file for the icon. This allows you to use an icon of your own if
  365. you so wish.
  366.  
  367. The "l" switch causes the compiler to display each line of ACE source code 
  368. as it is being compiled.
  369.  
  370.  
  371. The "O" switch causes the assembly source code produced by ACE to be
  372. optimised.  At present, simple peephole optimisation is carried out.
  373. Assembly code size reductions of around 5% to 10% are usual. Speed
  374. improvements vary, depending upon the program, however I recommend the
  375. use of the -O switch for all programs where speed is the least bit
  376. important. As time goes by, ACE's optimiser will be improved.
  377.  
  378. The "w" switch tells ACE to include checks for window close-gadget clicks.
  379. ACE checks all open windows and upon detecting a close-gadget click, the
  380. clicked window is closed and the program exits. However, any other open
  381. windows or screens will not be closed. The use of ON WINDOW can get around 
  382. this by allowing for a user-defined clean-up subroutine
  383. (see the "@{"Event Trapping" link 3event}" section below).
  384.  
  385. The syntax for the bas script is:
  386.  
  387.     bas [-bcEilOw] <sourcefile> [<objectfile>]
  388.  
  389. where <sourcefile> is the program to be compiled (without the .b extension)
  390. and <objectfile> is a C or assembly module which has been (compiled and) 
  391. assembled to produce an object file.
  392.  
  393. The <objectfile> is linked with the output of ACE+A68K along with db.lib, 
  394. startup.lib and ami.lib. This is necessary when an external function or 
  395. variable in <objectfile> is referenced by an ACE program. For more about 
  396. external functions, see the section "@{"External references" link 3ref}" below.
  397. @ENDNODE
  398.  
  399. @NODE 2running "Running ACE programs" 
  400.  
  401. Running ACE programs
  402. --------------------
  403. ACE programs can be run from either a shell/CLI or Workbench. In the latter
  404. case a tool icon must be created for the executable. One has been provided
  405. with the archive in the icons directory (exe.info). Refer to the "i"
  406. switch in "@{"Compiler options" link 2options}" above re: automatic icon creation by the
  407. compiler.
  408.  
  409. As far as I can tell, ACE programs are pure and so can be made resident
  410. once the pure bit is set with the protect command. I've had no problems
  411. so far.
  412. @ENDNODE
  413.  
  414. @NODE 2example "About the example programs"
  415.  
  416. About the example programs
  417. --------------------------
  418. I have written a number of programs which illustrate most of the features
  419. of ACE up to this point and you should find these with the distribution.
  420.  
  421. Several programs are related to chaos theory and fractals - a pet interest 
  422. of mine (and of thousands of other programmers :). The remainder are an 
  423. assorted bunch which demonstrate ACE's capabilities.
  424.  
  425. The information for the chaos/fractal programs came from a wide variety of 
  426. sources. The algorithms for @{"henon.b" alink ace:prgs/fractals/henon.b/main} and @{"lorenz.b" alink ace:prgs/fractals/lorenz.b/main} came from "Dynamical
  427. systems and fractals: computer graphics experiments in Pascal"
  428. by Becker & Dorfler, 1990.
  429.  
  430. Some programs are optimised at the source level and some are not. You'll 
  431. find that using integer variables can often result in quite dramatic 
  432. improvements in program execution speed (eg: try replacing op% with op and 
  433. k% with k in @{"ifs.b" alink ace:prgs/ifs.b/main} and you'll see what I mean).
  434.  
  435. There are several examples which demonstrate the use of recursive 
  436. subprograms in ACE (eg: @{"fact.b" alink ace:prgs/misc/fact.b/main}).
  437.  
  438. Another area of interest for me is neural networks and you'll find a 
  439. program called @{"hopnet.b" alink ace:prgs/misc/hopnet.b/main}, which shows graphically how a simple Hopfield 
  440. network changes under various conditions.
  441.  
  442. Other programs include a talking clock (@{"tclock.b" alink ace:prgs/tclock.b/main}), a sound sample player 
  443. (@{"play.b" alink ace:prgs/sound/play.b/main}) and a command-line calculator (@{"bc.b" alink ace:prgs/shellutils/bc.b/main}).
  444. @ENDNODE 
  445.  
  446. @NODE 3comments "General comments"
  447.  
  448. General comments
  449. ----------------
  450. I made a decision very early on in the project to allow standard I/O (for 
  451. shell/CLI). All other windows are (as of ACE v2.0) Intuition windows.
  452.  
  453. The execution speed of most programs (especially with graphics, eg: @{"ifs.b" alink ace:prgs/ifs.b/main})
  454. is, as you might expect, *fast* compared to interpreted AmigaBASIC.
  455.   
  456. No error messages are given at run-time (but file and serial I/O errors
  457. are reported by the @{"ERR" alink ace:docs/ref.guide/err} function), nor is there any stack overflow or
  458. array bounds checking. 
  459.  
  460. Labels are supported and can be used with @{"GOSUB" alink ace:docs/ref.guide/gosub..return} and @{"GOTO" alink ace:docs/ref.guide/goto}. Line numbers are 
  461. supported, but are only necessary for old BASIC programs. Also, ACE's rich 
  462. assortment of control constructs makes the use of GOTO largely redundant.
  463.  
  464. Available control constructs are: @{"WHILE..WEND" alink ace:docs/ref.guide/while..wend}, @{"REPEAT..UNTIL" alink ace:docs/ref.guide/repeat..until},
  465. IF..THEN..ELSE, @{"IF..THEN..ELSE..END IF" alink ace:docs/ref.guide/if}, @{"CASE..END CASE" alink ace:docs/ref.guide/case}, @{"ON..GOTO" alink ace:docs/ref.guide/on..goto..gosub},
  466. @{"ON..GOSUB" alink ace:docs/ref.guide/on..goto..gosub}, @{"SUB..END SUB" alink ace:docs/ref.guide/sub..end_sub} and @{"GOSUB..RETURN" alink ace:docs/ref.guide/gosub..return}.
  467.  
  468. Apart from single line comments with @{"REM" alink ace:docs/ref.guide/rem} and ' ACE allows block comments
  469. with { and }. For example:
  470.  
  471.  { comments can span more than 
  472.    one line like this }
  473.  
  474. Multi-statements are also supported by ACE, eg:
  475.  
  476.  x$="hello":y$="there":say translate$(x$+" "+y$)
  477. @ENDNODE
  478.  
  479. @NODE 3preproc "The preprocessor and #include files"
  480.  
  481. The preprocessor and #include files
  482. ------------------------------------
  483. The ACE preprocessor: APP, is modest when compared to the C preprocessor.
  484.  
  485. Its main function thus far is for the inclusion of files with the #include 
  486. directive. As in C, #include "filename" looks for the file as specified, 
  487. while #include <filename> looks for the file in a local include directory 
  488. (see "@{"Installation" link 2installation}"). A file will only ever be included once.
  489.  
  490. The #include directive can also be used in included files, but since file 
  491. inclusion is recursive, watch your stack size (40000 bytes is plenty).
  492.  
  493. APP also handles single-line comments (text following a "'") and block
  494. comments (starting with "{" and ending with "}"). This is partly to allow
  495. #include commands to be commented out and also to make less work for the 
  496. compiler. However, the compiler does still handle comments in case the pre-
  497. processor isn't invoked. APP does not handle REM since this is a BASIC 
  498. statement.
  499.  
  500. The syntax for APP is: 
  501.  
  502.     app <source> <dest> 
  503.  
  504. The bas script uses APP by first preprocessing an ACE source file to the
  505. RAM:T directory.
  506.  
  507. Use of #include has the effect of adding lines to the preprocessed ACE 
  508. source, which has an impact upon the physical location of lines from the
  509. main ACE file when transfered to the destination file.
  510.  
  511. ACE include files have two purposes. As in C they can be used to include
  512. constants and structure definitions. Second, as with files like WBarg.h,
  513. ACE include files may contain subprogram definitions and although this is 
  514. quite possible in C, it seems to be less often done under the guise of .h 
  515. files. I have arbitrarily chosen to append all include files with .h but 
  516. there is no reason why this need be so. Purists will probably be aghast.
  517.  
  518. APP will be improved as time goes by. 
  519. @ENDNODE
  520.  
  521. @NODE 3data "Data types, expressions and constants" 
  522.  
  523. Data types, expressions and constants
  524. ------------------------------------- 
  525. The following fundamental data types are currently supported:
  526.  
  527.        - signed short integers (2 bytes = 16 bits)
  528.        - signed long integers  (4 bytes = 32 bits)
  529.        - single-precision: Motorola fast floating point (4 bytes = 32 bits)
  530.        - strings (default to 1024 bytes including ASCII 0 end-of-string)
  531.  
  532. Exponential and fixed-point formats are recognised by all ACE functions
  533. and in program text for single-precision numbers.
  534.  
  535. Expression parsing is the same as for AmigaBASIC, as is the precedence of
  536. operators. Evaluation of _all_ expressions proceeds from left to right.
  537. This includes exponentiation, so 2^3^2 will be evaluated as (2^3)^2.
  538.  
  539. In addition, due to the higher precedence of exponentiation over unary
  540. negation and the way ACE's recursive descent parser works, 4^(-2) is okay,
  541. but 4^-2 isn't.
  542.  
  543. ACE supports full 32-bit and single-precision floating point math:
  544.  
  545.     addition, subtraction, multiplication:
  546.         
  547.         - 16-bit integer
  548.         - 32-bit integer
  549.         - single-precision 
  550.  
  551.     division & modulo arithmetic:
  552.  
  553.         - 32-bit integer
  554.         - single-precision
  555.  
  556. Increment and decrement operators are provided in ACE in the following
  557. form:
  558.  
  559.     ++<variable> OR --<variable>
  560.  
  561.  
  562. The value of the simple or external variable is incremented or decremented
  563. by 1.
  564.  
  565. Notice that ++ and -- are pre-increment & pre-decrement operators ONLY.
  566. Those familiar with C will recognise these operators and their utility.
  567. In terms of efficiency: ++x is better than x=x+1.
  568.  
  569. Unlike interpreted AmigaBASIC, hexadecimal and octal constants can
  570. be either short or long values. This makes for nicer addressing with
  571. @{"PEEK" alink ace:docs/ref.guide/peekx} & @{"POKE" alink ace:docs/ref.guide/pokex}.
  572.  
  573. Trailing characters (%&!#) after constants cause coercion from one numeric
  574. data type to another, as in AmigaBASIC, eg:
  575.  
  576.        Delay(50&)   '..50 is coerced from short to long integer
  577.        x=12.5*65!   '..65 is coerced from short integer to single-precision
  578.  
  579. As in AmigaBASIC expression evaluation, all operands in an expression are 
  580. converted to the data type of the most precise operand. Logical operators 
  581. (@{"AND" alink ace:docs/ref.guide/and},@{"EQV" alink ace:docs/ref.guide/eqv},@{"IMP" alink ace:docs/ref.guide/imp},@{"NOT" alink ace:docs/ref.guide/not},@{"OR" alink ace:docs/ref.guide/or},@{"XOR" alink ace:docs/ref.guide/xor}) convert their operands to
  582. integer values as does the integer division operator "\". Relational
  583. operators (= <> > < >= <=) yield long integer results.  
  584.   
  585. ACE's boolean values are as follows: 0=false, N=true where N is any 
  586. non-zero long integer. Note that relational operations give -1 for true 
  587. (since: NOT -1 = 0).
  588.  
  589. ACE allows you to define named global signed numeric constants with the 
  590. @{"CONST" alink ace:docs/ref.guide/const} directive (see command and function reference).
  591.  
  592. Strings have a default length of 1K instead of the usual 32K, since ACE 
  593. programs reserve memory for each string immediately at run-time which could
  594. result in quite memory hungry executables if strings were too large. It is 
  595. possible however, to define strings which are longer or shorter than 1K
  596. (see @{"STRING" alink ace:docs/ref.guide/string} command).
  597.  
  598. ACE strings are NULL terminated, ie: the last character is an ASCII 0, as 
  599. in the C programming language.
  600.  
  601. A string literal without a final '"' will be truncated at the end of the 
  602. line.
  603. @ENDNODE
  604.  
  605. @NODE 3ops "Precedence of operators"
  606.  
  607. Precedence of operators
  608. -----------------------
  609. ACE follows AmigaBASIC in operator precedence, with the addition of
  610. structure dereferencing and indirection operators.
  611.  
  612.                             operators
  613.                             ---------
  614.  
  615.     1.  Structure Member Dereferencing,        ->
  616.         Parentheses and Address Operator        () @
  617.     2.  Indirection Operators            *% *& *!    
  618.     3.  Exponentiation                ^
  619.     4.  Unary Negation                -
  620.     5.  Multiplication and Floating-Point Division    * /
  621.     6.  Integer Division                \
  622.     7.  Modulo Arithmetic                MOD
  623.     8.  Addition and Subtraction            + -
  624.     9.  Relational Operators            = < > <= >= <>
  625.     10. NOT
  626.     11. AND
  627.     12. OR and XOR
  628.     13. EQV
  629.     14. IMP
  630.  
  631. The use of parentheses in an expression forces the enclosed term to be 
  632. evaluated before adjacent terms. Expression evaluation always proceeds 
  633. from left to right in ACE and AmigaBASIC.
  634. @ENDNODE
  635.  
  636. @NODE 3id "Identifiers" 
  637.   
  638. Identifiers
  639. -----------
  640. As in AmigaBASIC an identifier can consist of a combination of letters, 
  641. numbers and periods (".") up to a maximum length of 40 characters. 
  642.  
  643. In ACE the underline ("_") character is also legal. An ACE identifier must 
  644. start with either a letter or an underline character.
  645.  
  646. An identifier can be used to represent the following:
  647.  
  648.         - labels
  649.         - arrays
  650.         - variables
  651.         - structures
  652.         - parameters
  653.         - subprograms
  654.         - defined functions
  655.         - named constants
  656.         - shared library functions
  657.         - external functions or variables
  658.  
  659. Labels are global in ACE, so a main program label and a @{"SUB" alink ace:docs/ref.guide/sub..end_sub} label cannot 
  660. have the same name.
  661.  
  662. Identifiers can have a qualifier character (%&$!#) appended in order to 
  663. indicate data type, where:
  664.  
  665.         % = short integer
  666.         & = long integer
  667.         ! = single-precision
  668.         # = double-precision -> not supported yet
  669.         $ = string    
  670.  
  671. Examples of valid identifiers are:
  672.  
  673.         x3
  674.         num&
  675.         _putchar
  676.         play.sound
  677.  
  678. An identifer with no qualifier has a default type of single-precision. The 
  679. @{"DEFxxx" alink ace:docs/ref.guide/defxxx} compiler directives (see command and function reference) have the
  680. same effect as the qualifier characters except they affect all identifiers
  681. starting with a certain letter. Qualifier characters have higher
  682. precedence than DEFxxx directives. 
  683.  
  684. For shared library functions and external references, a qualifier is used
  685. merely to declare data type. So for example, an external function might be 
  686. declared thus:
  687.  
  688.         external function RangeRand%
  689.  
  690. but can later be referred to as RangeRand.
  691.  
  692. The declaration of external functions/variables and shared library
  693. functions is global no matter where the declaration occurs.
  694.  
  695. Defined constants are unaffected by qualifier characters. 
  696.  
  697. The _value_ of a defined constant determines its type.
  698. Thus CONST x&=1.2 is a single-precision - NOT a long integer - constant.
  699. Needless to say therefore, it is unwise to use qualifier characters for
  700. named constants.
  701.  
  702. The declaration of constants (with @{"CONST" alink ace:docs/ref.guide/const}) is always global whether the
  703. declaration takes place in the main program or a subprogram.
  704.  
  705. Structure variables hold a long integer value (address), so trailing 
  706. characters have no effect.
  707.  
  708. Structure type definitions are global, but structure variable declarations
  709. are local.
  710.  
  711. ACE allows for *optional* variable declarations with the @{"SHORTINT" alink ace:docs/ref.guide/shortint}, @{"LONGINT" alink ace:docs/ref.guide/longint},
  712. @{"ADDRESS" alink ace:docs/ref.guide/address}, @{"SINGLE" alink ace:docs/ref.guide/single} and @{"STRING" alink ace:docs/ref.guide/string} directives. Such declarations are useful in
  713. that:
  714.     
  715.         (i)    They ensure that a variable has a NULL or zero 
  716.             value.
  717.  
  718.         (ii)    They prevent dangerous errors which result from 
  719.             the misspelling of variable names.
  720.  
  721.         (iii)    Most languages have them and they serve to 
  722.             document variable usage explicitly.
  723.  
  724.         (iv)    They provide a "cleaner" way of establishing a 
  725.             variable which is to be shared by a subprogram.
  726.  
  727. My feeling on the matter of variable declarations is that in a small
  728. program they probably aren't necessary so long as you are careful, but
  729. in a large program all major variables should be declared for safety.
  730.   
  731. Variable declarations override the @{"DEFxxx" alink ace:docs/ref.guide/defxxx} compiler directives and qualifier
  732. characters and are local to the current level (main program or subprogram).
  733.  
  734. Summary of identifier properties:
  735.  
  736. +---------------+---------------+------------------+
  737. | Identifier    | Local/Global  | Affected by %&!$ |
  738. +---------------+---------------+------------------+
  739. | ARRAY        | LOCAL        | YES            |
  740. | SIMPLE VAR    | LOCAL        | YES           |
  741. | STRUCTURE VAR | LOCAL        | NO           |            
  742. | PARAMETER    | LOCAL        | YES           |
  743. | STRUCTURE DEF | GLOBAL    | NO           |        
  744. | LABEL        | GLOBAL    | NO           |
  745. | NAMED CONST   | GLOBAL    | NO           |
  746. | SUBPROGRAM     | GLOBAL    | YES           | 
  747. | DEF FN     | GLOBAL    | YES           |
  748. | LIBRARY FUNC  | GLOBAL    | YES (declaration)|
  749. | EXT VAR/FUNC    | GLOBAL    | YES (declaration)|
  750. +---------------+---------------+------------------+
  751. @ENDNODE
  752.  
  753. @NODE 3indirect "Indirection operators" 
  754.    
  755. Indirection operators
  756. ---------------------
  757. ACE has four indirection operators: @,*%,*&, and *!. These are _similar_
  758. to pointers in C.
  759.  
  760.       @<object>   - returns the absolute address of a data object.
  761.                   - note that this is identical to @{"VARPTR" alink ace:docs/ref.guide/varptr}(<object>).
  762.       *%<address> - peeks or pokes a short value at the specified address.
  763.       *&<address> - peeks or pokes a long value at the specified address.
  764.       *!<address> - peeks or pokes a single value at the specified address.
  765.  
  766. The indirection operators can therefore be used in a statement (poke)
  767. and/or as part of an expression (peek), for example:
  768.  
  769.     address x
  770.     y=23.25
  771.     x=@y
  772.     *!x := *!x + 2
  773.     print y
  774.  
  775. will print a value of 25.25.
  776.  
  777. There are two things to notice here. First, the pointers are to addresses, 
  778. not necessarily connected to variables. It would be quite legal to allocate
  779. an area of memory and then dereference it with these operators.
  780.  
  781. Second, when assigning a value to a dereferenced memory location as in the 
  782. above example, the ":=" symbol must be used, simply because of the way the 
  783. parser processes statements. Pascal programmers will recognise this as 
  784. the assignment operator. 
  785.  
  786. See also the section below for information about how to use these operators
  787. to implement variable parameters (call-by-reference) for simple variables
  788. in ACE subprograms.
  789. @ENDNODE
  790.  
  791. @NODE 3files "Files"
  792.  
  793. Files
  794. -----
  795. AmigaBASIC sequential files are supported and random files are on the list 
  796. of things to do.
  797.  
  798. The commands and functions for manipulating sequential files in ACE are:
  799.  
  800. commands:
  801.     - @{"OPEN" alink ace:docs/ref.guide/open}
  802.     - @{"CLOSE" alink ace:docs/ref.guide/close}
  803.     - @{"PRINT#" alink ace:docs/ref.guide/print_#}
  804.     - @{"WRITE#" alink ace:docs/ref.guide/write}
  805.     - @{"INPUT#" alink ace:docs/ref.guide/input_#}
  806.     - @{"LINE INPUT#" alink ace:docs/ref.guide/line_input}
  807.  
  808. functions:
  809.     - @{"INPUT$" alink ace:docs/ref.guide/input$}
  810.     - @{"EOF" alink ace:docs/ref.guide/eof}
  811.     - @{"LOF" alink ace:docs/ref.guide/lof}
  812.     - @{"HANDLE" alink ace:docs/ref.guide/handle} *
  813.  
  814.     * not found in AmigaBASIC
  815.  
  816. Note that for any command which is immediately followed by a # there
  817. should be at least one space between the keyword and the #, even though
  818. I may refer to such commands as <name># in the text of this document and
  819. in @{"Ref.Guide" alink ace:docs/ref.guide/main}.
  820.  
  821. See the command and function reference for details of each of these.
  822.  
  823. When WRITE# is used, the result is identical to AmigaBASIC. For example:
  824.  
  825.     X=12 : Y=-3.2 : Z$="fun eh?"
  826.     OPEN "O",#1,"stuff"
  827.       WRITE #1,X,Y,Z$
  828.     CLOSE #1
  829.  
  830. results in a one-line file of the following format:
  831.  
  832.     12,-3.2,"fun eh?"
  833.  
  834. On the other hand, if the following is used instead: 
  835.  
  836.     PRINT #1,X,Y,Z$ 
  837.  
  838. the file format will be:
  839.  
  840.      12         -3.2        fun eh?
  841.  
  842. while if semicolons are used:
  843.  
  844.     PRINT #1,X;Y;Z$
  845.  
  846. the file format becomes:
  847.  
  848.      12 -3.2 fun eh?
  849.  
  850. INPUT# (eg: INPUT #1,X,Y,Z$) can be used to read values from a file in any 
  851. of the above formats, but bear in mind that strings that are not delimited
  852. by quotes, but contain spaces or tabs will be seen as more than one string 
  853. by INPUT#. So, in the example formats above, while 
  854.  
  855.     "fun eh?" 
  856.  
  857. is one string,
  858.  
  859.     fun eh?
  860.  
  861. is two strings as far as INPUT# is concerned.
  862.  
  863. The formats of sequential files in ACE and AmigaBASIC are now very nearly
  864. identical, the only differences being in ACE tabs (produced by comma 
  865. delimiters in PRINT -- see @{"PRINT" alink ace:docs/ref.guide/print} in Ref.Guide) and the number of decimal 
  866. places written for single-precision values (usually more in ACE).
  867.   
  868. If you find ACE file I/O too slow, you may want to use the dos.library 
  869. functions (eg: xRead, xWrite). For this reason, I have included the HANDLE
  870. function which returns the AmigaDOS handle of a file opened with ACE's
  871. OPEN command. You may also wish to use the ami.lib buffered file I/O
  872. functions which also require this handle. If HANDLE returns 0, the file
  873. doesn't exist.
  874.  
  875. See prgs/IO/@{"print.b" alink ace:prgs/io/print.b/main} for an example of opening a sequential file to a
  876. printer. 
  877.  
  878. Although SER: may be opened as a sequential file, it is not possible to 
  879. specify parameters for the serial port (baud rate etc) by this method as 
  880. is possible in AmigaBASIC.
  881.  
  882. Instead, ACE provides a set of special serial I/O commands. See Ref.Guide
  883. for details of @{"SERIAL OPEN" alink ace:docs/ref.guide/serial_open}/@{"CLOSE" alink ace:docs/ref.guide/serial_close} etc, and prgs/IO/@{"aterm.b" alink ace:prgs/io/aterm.b/main} for a simple
  884. terminal program.
  885. @ENDNODE
  886.  
  887. @NODE 3clwb "Command line and Workbench arguments"
  888.  
  889. Command line and Workbench arguments
  890. ------------------------------------
  891. When called from a Shell or CLI, an ACE program may have arguments, eg:
  892.  
  893.     tree 30
  894.  
  895. Arguments can be accessed by two ACE functions:
  896.  
  897.     @{"ARGCOUNT" alink ace:docs/ref.guide/argcount} and @{"ARG$" alink ace:docs/ref.guide/arg$}(n)
  898.  
  899. The former returns a short integer value indicating the number of arguments
  900. for the current program, while the latter returns the nth argument as a
  901. string where n ranges from 0 to argcount. The zeroth argument
  902. (ie: ARG$(0)) is the name of the program.
  903.  
  904. Workbench arguments are currently supported by ACE in the form of four 
  905. functions in the include file WBarg.h: WBargcount, WBarg$(n),
  906. WBargPath$(n) and WBargLock&(n).
  907.  
  908. The first three are the most useful. The fourth is mainly for use by 
  909. WBargPath$. 
  910.  
  911. WBargcount returns the number of arguments passed to a program as icons.
  912. As with ARG$(0), the zeroth Workbench argument is the name of the program.
  913.  
  914. To pass arguments to a program via Workbench one of the shift keys is held 
  915. down while the icons which represent the arguments to be passed are
  916. activated.  While still depressing the shift key, the application icon is
  917. double clicked. 
  918.  
  919. An alternative method of passing arguments is to change the default tool
  920. of a project icon (eg: document) with the Info option from Workbench.
  921.  
  922. When this project icon is double clicked, the default tool will be loaded.
  923. In this case, if the source code of the default tool (the program) had a
  924. line such as:
  925.  
  926.     x$ = WBarg$(1)
  927.  
  928. x$ would contain the name of the project file.
  929.  
  930. WBargPath$(n) is used to find the full path of the file name and includes 
  931. trailing ":" and "/" characters.
  932.  
  933. See the include file WBarg.h for further descriptions of each function.
  934. @ENDNODE
  935.  
  936. @NODE 3subs "Subprograms"
  937.       
  938. Subprograms
  939. -----------
  940. Subprograms are supported by ACE, but differ from AmigaBASIC subprograms in
  941. a number of ways. Namely, ACE subprograms:
  942.  
  943.     - Are non-static,
  944.  
  945.     - Allow recursion,
  946.  
  947.        - Can be assigned return values.
  948.  
  949. By way of explanation, being non-static means that once a subprogram has 
  950. finished execution, its local variables and parameters cease to exist so 
  951. far as the rest of the program is concerned.
  952.  
  953. Recursive subprograms are an important feature of modern general
  954. programming languages. For several examples of the use of recursion, see
  955. the included programs (eg: @{"fact.b" alink ace:prgs/misc/fact.b/main}, @{"hanoi.b" alink ace:prgs/misc/hanoi.b/main}, @{"tree.b" alink ace:prgs/turtle/tree.b/main}).
  956.  
  957. A word of warning about recursion: it can be stack hungry, so it's a good 
  958. idea to set your stack to 20000 or so, just to be safe, although in most 
  959. cases, this will be a lot more than you need. From Workbench, simply
  960. change the tool's stack size with Info, or with the STACK command in a
  961. shell.
  962.  
  963. As with AmigaBASIC, ACE subprogram declarations cannot be nested.
  964.  
  965. The syntax of a subprogram call is the same as in AmigaBASIC:
  966.  
  967.     [CALL] sub-name[(parameter-list)]
  968.  
  969. The only difference is that the parentheses around the parameter list are
  970. not optional when @{"CALL" alink ace:docs/ref.guide/call} is omitted -- unless there are NO parameters. 
  971.  
  972. CALL *must* be used after THEN in a single-line @{"IF..THEN" alink ace:docs/ref.guide/if} statement.
  973.  
  974. By default, every subprogram has a return type of single-precision (just
  975. like variables). The @{"DEFxxx" alink ace:docs/ref.guide/defxxx} directives can be used to change the default
  976. data type of subprograms, as can the trailing characters !#$&%.
  977. A subprogram name can also be preceded by @{"SHORTINT" alink ace:docs/ref.guide/shortint},@{"LONGINT" alink ace:docs/ref.guide/longint},@{"ADDRESS" alink ace:docs/ref.guide/address},@{"SINGLE" alink ace:docs/ref.guide/single}
  978. or @{"STRING" alink ace:docs/ref.guide/string} as yet another alternative to setting the subprogram's return
  979. type.
  980.  
  981. The fact that ACE subprograms can be easily used as functions pretty much 
  982. obviates the need for @{"DEF FN" alink ace:docs/ref.guide/def_fn}.  However for reasons of compatibility with 
  983. AmigaBASIC and other BASICs, as well as its utility for simple functions, 
  984. ACE supports DEF FN (as of v2.0). 
  985.  
  986. A subprogram is given a value either inside the body of the relevant 
  987. subprogram or in the main program (eg: to zero it) - ala Pascal - thus:
  988.  
  989.     sub-name = <expression>
  990.  
  991. However, subprograms cannot be assigned a value in any other way (eg: with
  992. @{"INPUT" alink ace:docs/ref.guide/input} or @{"READ" alink ace:docs/ref.guide/read}).
  993.  
  994. A subprogram can be used in an expression, whereupon the subprogram is
  995. called and its value pushed onto the stack for inclusion in the final
  996. result of the expression, eg: 
  997.  
  998.     x=n*pow(n)
  999.  
  1000. where "pow" is a subprogram with one parameter.
  1001.  
  1002. While subprogram declarations can appear anywhere within the program text,
  1003. ACE requires that declarations precede calls. So:
  1004.  
  1005.     sub test
  1006.       print "hello"
  1007.      end sub
  1008.  
  1009.     test
  1010.  
  1011. is legal, but:
  1012.  
  1013.     test
  1014.  
  1015.     sub test
  1016.       print "hello"
  1017.      end sub
  1018.  
  1019. is not, and will yield an "undeclared subprogram" error. To get around
  1020. this, a forward declaration can be used:
  1021.  
  1022.     declare sub test
  1023.     
  1024.     test
  1025.  
  1026.     sub test
  1027.       print "hello"
  1028.     end sub
  1029.  
  1030. Forward declarations can include a parameter list. If you later declare
  1031. the actual @{"SUB" alink ace:docs/ref.guide/sub..end_sub} with a different parameter list and you've already called 
  1032. the subprogram after a forward declaration, the results will be
  1033. unpredictable.  I may place tighter controls on this at some stage.
  1034.  
  1035. Actual parameters are checked for number and type against formals, and 
  1036. parameter count mismatches result in a compilation error. An actual
  1037. parameter is coerced to the formal parameter's type.
  1038.  
  1039. ACE's parameter passing mechanism for subprograms is NOT the same as that
  1040. used for assembly code routines or external functions. In other words, the 
  1041. standard C parameter passing mechanism is not used for SUBs. This may be 
  1042. changed in the future as it makes object modules written in ACE
  1043. incompatible with C or assembler object modules in this respect.
  1044.   
  1045. Changes made to a formal parameter have no effect upon the actual
  1046. parameter in a simple call to an ACE subprogram, but see "@{"Limitations" link 4limit}"
  1047. re: overwriting of strings/arrays during recursive calls;
  1048. see also "@{"Structures" link 3struct}" below. 
  1049.  
  1050. The formal parameter list consists of identifiers separated by commas.
  1051. Each identifier may also be preceded by: @{"SHORTINT" alink ace:docs/ref.guide/shortint},@{"LONGINT" alink ace:docs/ref.guide/longint},@{"ADDRESS" alink ace:docs/ref.guide/address},@{"SINGLE" alink ace:docs/ref.guide/single}
  1052. or @{"STRING" alink ace:docs/ref.guide/string} to avoid the use of a qualifier (%&!$).
  1053.  
  1054. Actual parameters can basically be any type of expression. A whole array 
  1055. cannot be passed as a value parameter in ACE however.
  1056.  
  1057. There is an arbitrary upper limit of 40 parameters per subprogram at the
  1058. moment, which may be removed at some stage.
  1059.  
  1060. Main program variables and arrays can be accessed and modified within 
  1061. subprograms via the @{"SHARED" alink ace:docs/ref.guide/shared} directive. All shared variables are passed by 
  1062. reference to a subprogram.
  1063.  
  1064. Multiple SHARED statements are allowed within a single subprogram.
  1065.  
  1066. DIM SHARED is not allowed. An array is declared to be shared in exactly
  1067. the same way as simple variables, for example:
  1068.  
  1069.     DIM x(10)
  1070.  
  1071.     sub thing
  1072.         shared x
  1073.         .
  1074.         .
  1075.         end sub
  1076.  
  1077. Note that parentheses are not required after an array in the shared
  1078. statement, nor are they legal in ACE.
  1079.  
  1080. The differences between variable parameters and shared variables in ACE 
  1081. are that:
  1082.  
  1083.     - Shared variables only allow access to main program
  1084.       variables from a subprogram, and do not provide a
  1085.       mechanism for changing the value of variables in 
  1086.           one subprogram from another.  
  1087.  
  1088.         - The name of a variable to be shared must correspond
  1089.       to the name of an existing (ie: already referenced/declared) 
  1090.           main program variable.
  1091.  
  1092. Although variable parameters are not explictly provided by ACE there are 
  1093. two ways to implement them: using indirection operators for simple
  1094. variables and the @{"ADDRESS" alink ace:docs/ref.guide/address} option of @{"DIM" alink ace:docs/ref.guide/dim} and @{"STRING" alink ace:docs/ref.guide/string}.
  1095. (see also "@{"Structures" link 3struct}" section).
  1096.  
  1097. Here's an example of call-by-reference parameters for simple variables
  1098. (@{"DEFxxx" alink ace:docs/ref.guide/defxxx} directives are used here for clarity):
  1099.  
  1100.     deflng x  '..x is an address holder
  1101.     defsng n  '..n is a single-precision variable
  1102.  
  1103.     sub doub(x)
  1104.        *!x := *!x * 2  '...n=n*2 [note the ":=" symbol!]
  1105.     end sub
  1106.  
  1107.     n=22.5
  1108.     print n
  1109.     doub(@n)  '..pass the address of n
  1110.     print n
  1111.  
  1112. which passes the single-precision variable n by reference to the
  1113. subprogram doub, where n is doubled. This will first print 22.5 and
  1114. then 45.
  1115.  
  1116. For an array, the following could be done:
  1117.  
  1118.     deflng    x  '..x is an address holder
  1119.  
  1120.     sub test(x)
  1121.     dim a(10) address x  '..points to n
  1122.       a(3)=a(3)+12
  1123.     end sub
  1124.  
  1125.     dim n(10)
  1126.     n(3)=2
  1127.     print n(3)
  1128.     test(@n)
  1129.     print n(3)
  1130.  
  1131. which would print first 2 and then 14.
  1132.  
  1133. The same mechanism can be used to pass a string variable by reference.
  1134.  
  1135. These variable parameter mechanisms are most useful when used to pass data 
  1136. *between* subprograms, otherwise it is simpler to use @{"SHARED" alink ace:docs/ref.guide/shared} variables.
  1137.    
  1138. The following table shows the possibilities regarding parameters and
  1139. shared 
  1140. variables in ACE:
  1141.  
  1142. +---------------------+--------+---------+--------------------------------+
  1143. | Data Type / Object  |    Shared |  Value  |    Variable parameters       |
  1144. |                     |        |  param  |                                |
  1145. |---------------------+--------+---------+--------------------------------+
  1146. | SHORTINT VARIABLE   |    YES    | YES     |  YES - *%addr              |
  1147. |              |           |     |                  |
  1148. | LONGINT/ADDRESS VAR |    YES    | YES     |  YES - *&addr              |
  1149. |              |           |     |                      |
  1150. | SINGLE VARIABLE     |    YES    | YES     |  YES - *!addr              |
  1151. |              |           |     |                      |
  1152. | STRING VARIABLE     |    YES    | YES     |  YES - STRING x ADDRESS addr   |
  1153. |                     |        |         |                                |
  1154. | EXTERNAL VARIABLE   |    NO     | YES     |  YES - *%, *&, *!, STRING ..   |
  1155. |              |           |     |                        |
  1156. | ARRAY              |    YES    | NO     |  YES - DIM x ADDRESS addr      |
  1157. |              |           |     |                      |
  1158. | STRUCTURE          |    YES    | NO     |  YES - See "@{"Structures" link 3struct}" below. |
  1159. +---------------------+--------+---------+--------------------------------+
  1160.  
  1161. Note: In the above table, "addr" is a long integer address. @{"VARPTR" alink ace:docs/ref.guide/varptr} or @ 
  1162. can be used to obtain this. The address is passed to the @{"SUB" alink ace:docs/ref.guide/sub..end_sub} by value. 
  1163. @ENDNODE
  1164.  
  1165. @NODE 3struct "Structures"
  1166.     
  1167. Structures
  1168. ----------
  1169. Structures have been included in ACE mainly because of their utility in 
  1170. gaining access to operating system functions. 
  1171.  
  1172. Legal structure members are of the following type: BYTE (in structures
  1173. only), @{"SHORTINT" alink ace:docs/ref.guide/shortint}, @{"LONGINT" alink ace:docs/ref.guide/longint}, @{"ADDRESS" alink ace:docs/ref.guide/address}, @{"SINGLE" alink ace:docs/ref.guide/single}, @{"STRING" alink ace:docs/ref.guide/string}. The latter ca
  1174.  have an
  1175. optional size specification.
  1176.  
  1177. If an array or structure is required as a structure member, it is necessary
  1178. to use STRING <ident> SIZE <bytes>. The address of the member can then be
  1179. found with @ or @{"VARPTR" alink ace:docs/ref.guide/varptr} and assigned to an array or structure variable.
  1180.  
  1181. If you want to have an address (ie: pointer to an object) as a structure 
  1182. member simply declare it as an item of type ADDRESS (or LONGINT).
  1183.  
  1184. When declaring a structure, the only difference between the following two
  1185. forms:
  1186.  
  1187.         DECLARE STRUCT mystructtype mystruct
  1188.     and
  1189.         DECLARE STRUCT mystructtype *mystruct
  1190.  
  1191. is that for the former, an appropriate data object is created (on a long
  1192. word boundary), but not for the latter.
  1193.  
  1194. In both cases, mystruct contains the start address of a structure of type 
  1195. mystructtype. In the second case, the address is NULL until assigned a
  1196. value (eg: with @{"ALLOC" alink ace:docs/ref.guide/alloc}). In both cases, the address can be reassigned at
  1197. will, although this should only really be done for structure pointers
  1198. (the second form).
  1199.  
  1200. Since both forms of structure declaration result in an address being stored
  1201. (in mystruct in the example), the dereferencing operator is always "->".
  1202.  
  1203.     examples:
  1204.     --------
  1205.  
  1206.     PRINT mystruct          -  prints the start address of the structure.
  1207.  
  1208.     PRINT mystruct->mins -     prints the value of a member called mins.
  1209.   
  1210. The @{"SIZEOF" alink ace:docs/ref.guide/sizeof} function can be used to determine the size of a structure type
  1211. if allocating memory for a structure (see @{"linkedlist.b" alink ace:prgs/misc/linkedlist.b/main}).
  1212.  
  1213. ACE structures are stand-alone data objects, and cannot be elements in an 
  1214. array (although structure addresses can be).
  1215.  
  1216. ACE structures can be @{"SHARED" alink ace:docs/ref.guide/shared} to allow its member's values to be modified, 
  1217. or a structure's address can be passed to a subprogram, eg:
  1218.  
  1219.     struct my
  1220.        longint one
  1221.        longint two
  1222.     end struct
  1223.     
  1224.     sub test(addr&)
  1225.     declare struct my *second
  1226.        second=addr&
  1227.        second->one = second->one * 2
  1228.     end sub
  1229.  
  1230.     '..main
  1231.     declare struct my first
  1232.     first->one=12
  1233.     print first->one
  1234.     test(first)
  1235.     print first->one
  1236.  
  1237. which will print 12 followed by 24.
  1238.  
  1239. The following code allocates enough memory to hold a structure of type
  1240. "my" gives values to the structure's 2 members, and changes the address
  1241. held by the structure variable "third" to the start of the newly allocated
  1242. memory area:
  1243.  
  1244.     const PUBLIC=2
  1245.  
  1246.     declare struct my *third
  1247.  
  1248.     sub create(ADDRESS a_struct)
  1249.     declare struct my *temp
  1250.       temp = Alloc(sizeof(my),PUBLIC)
  1251.       temp->one = 16
  1252.       temp->two = 10
  1253.       *&a_struct := temp    '..change structure variable's value
  1254.     end sub
  1255.  
  1256.     '..main
  1257.     create(@third)
  1258.     .
  1259.     .
  1260.  
  1261. Finally, it is not currently possible to use @{"INPUT" alink ace:docs/ref.guide/input}, @{"(LINE)" alink ace:docs/ref.guide/line_input} @{"INPUT#" alink ace:docs/ref.guide/input_#} or @{"READ" alink ace:docs/ref.guide/read} 
  1262. in conjunction with structures.
  1263. @ENDNODE
  1264.  
  1265. @NODE 3lib "Shared library function calls"
  1266.     
  1267. Shared library function calls
  1268. -----------------------------
  1269. ACE provides access to shared libraries in the same way as AmigaBASIC does
  1270. with the exception that you MUST declare a function in order to use it. 
  1271.  
  1272. Also, the library in question must either be in LIBS: or in ROM.
  1273.  
  1274. As of version 2.0, ACE and AmigaBASIC are otherwise pretty much the same. 
  1275. The ACE commands also retain their earlier syntax for backward
  1276. compatibility and convenience.
  1277.  
  1278. The commands are as follows:
  1279.  
  1280. @{"LIBRARY" alink ace:docs/ref.guide/library} <libname>    
  1281.  
  1282.     - Where <libname> is the name of a shared library with or 
  1283.       without quotes (eg: "graphics", "graphics.library", graphics).
  1284.  
  1285.     - A ".library" or ".bmap" suffix is allowed but optional.
  1286.  
  1287.            - The LIBRARY command opens the shared library and provides
  1288.       a copy of its base address for use internally by function 
  1289.       calls.
  1290.  
  1291.     - If a library can't be opened at run-time, the program 
  1292.       will abort.
  1293.  
  1294.  
  1295. LIBRARY CLOSE [<libname>]
  1296.  
  1297.     - Closes the specified shared library or all open libraries
  1298.       if no library name is given.
  1299.  
  1300.     - Closing a library more than once will cause no harm.
  1301.  
  1302.  
  1303. Notes about standard libraries used by ACE:
  1304.  
  1305.     - There are currently six standard libraries which are often opened
  1306.       by ACE routines during a program run. These are: dos, intuition,
  1307.       graphics, mathffp, mathtrans and translator libraries.
  1308.  
  1309.     - If one of these six is opened by the LIBRARY command it will 
  1310.       be opened at the start of the program *and* closed at the end. 
  1311.       Any other library will be opened and closed at the points in 
  1312.       the program specified by you.
  1313.  
  1314.     - You don't actually have to close any of the six libraries 
  1315.       mentioned above, but it won't hurt.
  1316.  
  1317.     - Moreover, you never have to open or close the dos.library
  1318.       since ACE opens it for EVERY program.
  1319.  
  1320.  
  1321. @{"DECLARE" alink ace:docs/ref.guide/declare} FUNCTION <funcname>[%&!#$][(param-list)] LIBRARY [<libname>]
  1322.         
  1323.     - Where <funcname> is the case sensitive name of a function in a
  1324.       shared library.
  1325.  
  1326.     - <funcname> may have a trailing character (&%#!$) to indicate
  1327.           type, otherwise default data type rules apply for the function's
  1328.           return value. This character is optional when @{"CALL" alink ace:docs/ref.guide/call}ing the
  1329.           function.
  1330.  
  1331.     - The optional parameter-list is for documentation purposes only
  1332.       and is otherwise ignored.
  1333.  
  1334.     - If <libname> (same as for LIBRARY and LIBRARY CLOSE) is
  1335.           specified, ACE only looks in the bmap file for that library,
  1336.           otherwise ACE looks for the function in the bmap files for
  1337.           all open libraries and all the standard libraries known to
  1338.           the compiler.  Needless to say that specifying <libname> results
  1339.           in faster bmap file entry lookups. This option is not given
  1340.           by AmigaBASIC however.
  1341.  
  1342.     - Example: DECLARE FUNCTION SetSoftStyle LIBRARY
  1343.  
  1344.  
  1345. [@{"CALL" alink ace:docs/ref.guide/call}] <funcname>[(parameter-list)]
  1346.  
  1347.     - Transfers control to the function <funcname>, loading the
  1348.       appropriate registers before doing so, according to the
  1349.       information about that function in the library's bmap file. 
  1350.  
  1351.      - The return value of a function can be accessed by calling
  1352.       a function as part of an expression, eg: addr& = AllocMem(100,2).
  1353.  
  1354. Function declarations are GLOBAL. They are are NOT optional in ACE.
  1355.  
  1356. ** PLEASE NOTE ***
  1357. No type checking of parameters is performed, so expect weirdness if you
  1358. pass values of the wrong type. If the RKM or whatever reference you are
  1359. using for library functions says to use a long integer, then do so.
  1360. Don't assume that a short integer will be coerced to a long integer.  It
  1361. won't. ACE cannot get that information from the bmap file in which a
  1362. function is found and parameters are not sign-extended by default.
  1363.  
  1364. When passing strings as parameters it is not necessary to add a CHR$(0)
  1365. to the end of a string since ACE strings are already NULL terminated. 
  1366.  
  1367. Either @{"VARPTR" alink ace:docs/ref.guide/varptr} or @{"SADD" alink ace:docs/ref.guide/sadd} can safely be used to find the address of a string 
  1368. variable or constant. Actually, the use of SADD or VARPTR for strings
  1369. passed to library functions is optional, but it's probably a good idea to 
  1370. use one or the other all the time, for consistency's sake. These comments 
  1371. also apply to calling machine code routines and external functions.
  1372.   
  1373. It is up to YOU to open and close libraries correctly. ACE doesn't keep
  1374. track of this, and will try to jump to a library function so long as 
  1375. it finds a reference to it in a bmap file even if the library hasn't 
  1376. been opened! As mentioned above, it is not necessary to open and close 
  1377. dos.library because _every_ ACE program does this.
  1378.  
  1379. ACE expects the bmap file for a library to be in the directory ACEbmaps:
  1380. (see "@{"Installation" link 2installation}"). I have been advised by Commodore Australia that 
  1381. these files may be distributed with ACE but I will wait until I have this 
  1382. in writing before providing them with the archive (I've waited several 
  1383. months already).
  1384.  
  1385. As of version 2.0, I have provided a program (FD2BMAP) which is
  1386. functionally equivalent to ConvertFD (since this may NOT be freely
  1387. redistributed) so that bmap files for new libraries can be created.
  1388. The source code for FD2BMAP is to be found in the ACE:utils/fd2bmap
  1389. directory and was written in ACE by Harald Schneider, with some
  1390. modifications by me.
  1391.  
  1392. The 1.3 FD files can be found in the BasicDemos drawer on the Extras disk. 
  1393. The FD files for Release 2.x/3.0 are available from Commodore for about
  1394. $30 (you get six disks of developer goodies: ask for the Native Developers
  1395. Kit).
  1396.  
  1397. AmigaBASIC cannot handle functions which use address register a5. This is 
  1398. not true for ACE. Neither ACE nor AmigaBASIC allow the use of functions
  1399. which use register a6.
  1400.  
  1401. See @{"library.b" alink ace:prgs/library/library.b/main} for an example of how to use shared library functions in ACE.
  1402. @ENDNODE
  1403.  
  1404. @NODE 3machine "Machine code calls" 
  1405.   
  1406. Machine code calls
  1407. ------------------
  1408. ACE supports AmigaBASIC's mechanism for calling machine code routines and
  1409. the passing of parameters to such routines. AmigaBASIC's stack conventions 
  1410. are also followed (ie: C style parameter passing).
  1411.  
  1412. The syntax for calling such a routine is:
  1413.  
  1414.     CALL long-integer-variable-name[(parameter-list)]
  1415.  
  1416. Note that @{"CALL" alink ace:docs/ref.guide/call} is NOT optional. Also, the variable containing the address 
  1417. of the routine *must* be a long integer in ACE.
  1418.  
  1419. For example, 
  1420.  
  1421.     CALL caps&(length&,addr&)
  1422.  
  1423. will set up the stack like this:
  1424.     
  1425.     8(sp) = addr& 
  1426.     4(sp) = length&
  1427.     0(sp) = return address
  1428.  
  1429. on entry to the machine code subroutine caps&.
  1430.  
  1431. On exit from a routine, ACE cleans up the stack by POPping all parameters.
  1432.  
  1433. You can use a short integer array, a string or an allocated area of memory
  1434. (with ACE's @{"ALLOC" alink ace:docs/ref.guide/alloc} function) to poke the bytes of a machine code routine
  1435. into.  I prefer the latter method.
  1436.  
  1437. Note that because ACE treats ASCII 0 as the end-of-string character, don't 
  1438. use the string-building method, eg:
  1439.  
  1440.     z$=""
  1441.     for i=1 to N
  1442.          read b
  1443.       z$=z$+chr$(b)
  1444.         next
  1445.  
  1446. since if b=0, chr$(b) will be the NULL string. If you want to use a string,
  1447. do the following:
  1448.  
  1449.     z$=""    '..or STRING z$ SIZE 100 (if there are 100 bytes of MC).
  1450.     addr&=sadd(z$)
  1451.     for i&=0 to N-1
  1452.       read b%
  1453.       poke addr&+i&,b%
  1454.     next
  1455.     call addr&
  1456.  
  1457. The latter is okay, so long as you don't allocate other strings with odd 
  1458. sizes. But if you want to be sure that you have an area of memory which 
  1459. is long-word aligned, use @{"ALLOC" alink ace:docs/ref.guide/alloc}, eg:
  1460.  
  1461.     addr&=Alloc(100,2)    '..100 bytes of PUBLIC memory
  1462.     for i&=0 to N-1
  1463.       read b%
  1464.       poke addr&+i&,b%
  1465.     next
  1466.     CALL addr&
  1467.  
  1468. The above examples assume the presence of appropriate @{"DATA" alink ace:docs/ref.guide/data} statements. See 
  1469. the prgs/MC directory for working examples.
  1470.  
  1471. ACE also supports inline assembly code inclusion. See @{"ASSEM..END ASSEM" alink ace:docs/ref.guide/assem} in 
  1472. Ref.Guide for details.
  1473. @ENDNODE
  1474.  
  1475. @NODE 3ref "External references" 
  1476.  
  1477. External references
  1478. -------------------
  1479. Reference can be made to a variable or function in another file which is
  1480. resolved at link time. You may for instance, have written a function in C
  1481. or assembler. It is possible to pass parameters to, call and obtain return
  1482. values (as with ACE SUBs) from such a function in ACE after declaring an 
  1483. external reference to the function with the @{"EXTERNAL" alink ace:docs/ref.guide/external} FUNCTION directive 
  1484. (see command and function reference for syntax).
  1485.  
  1486. When passing parameters, standard C parameter passing conventions 
  1487. are used. Although some C compilers seem to pass all parameters as
  1488. 4 bytes per parameter on the stack, ACE allows 2 (short words) or 4 
  1489. byte parameters. Be aware of this! See prgs/ExternFunc for examples.
  1490.  
  1491. External variables can be assigned values like normal variables, eg:
  1492.  
  1493.         external RangeSeed&
  1494.         RangeSeed=5276&
  1495.     
  1496. All external reference identifiers have an underscore prefixed by ACE but
  1497. this is optional when declaring or using an external reference. C
  1498. compilers prepend an underscore to external symbols, so ACE does too.
  1499.  
  1500. Note that the names of external references ARE case sensitive.
  1501.  
  1502. Also, the bas script can take as a third argument the name of the object 
  1503. file produced from the original C or assembly source (ie: .o or .lib file) 
  1504. which contains the external function or variable to be linked with your
  1505. ACE program. 
  1506.  
  1507. It's not easy to call ACE SUBs from C or assembler for two reasons:
  1508.  
  1509.     1. ACE SUBs don't currently use C parameter passing conventions.
  1510.     2. ACE produces whole  assembly source programs, not just functions
  1511.        like a C compiler does.
  1512.  
  1513. For now, you'll have to get your hands dirty with the assembly source code 
  1514. produced by ACE if you want to do this. ACE's -c switch may be of some
  1515. help here.
  1516. @ENDNODE
  1517.  
  1518. @NODE 3windows "Windows" 
  1519.         
  1520. Windows
  1521. -------
  1522. You can open up to nine user-defined windows on the Workbench screen. 
  1523. See the command and function reference for the syntax of the @{"WINDOW" alink ace:docs/ref.guide/window} 
  1524. statement.
  1525.  
  1526. All user-defined windows are now (as of ACE v2.0) Intuition windows with 
  1527. each characteristic being configurable via the "type" parameter as per 
  1528. AmigaBASIC (see @{"Ref.Guide" alink ace:docs/ref.guide/window}).
  1529.  
  1530. Windows can be opened on the Workbench screen or a user-defined screen.
  1531.  
  1532. The zeroth window (the shell/CLI, if the program was CLI launched) is now
  1533. the only instance of a DOS console window in ACE.
  1534.  
  1535. The WINDOW function takes a single parameter and returns information about
  1536. the current output window. See Ref.Guide for details.
  1537.  
  1538. Note that for user-defined windows, close-gadget clicks must be handled by 
  1539. the use of ON WINDOW event trapping or via the "w" compiler option.
  1540. @ENDNODE
  1541.  
  1542. @NODE 3screens "Screens"
  1543.  
  1544. Screens
  1545. -------
  1546. You can open 9 screens at once (memory permitting!).
  1547.  
  1548. By default, when a screen is opened, a BORDERLESS window the same size 
  1549. as the screen is also opened. Subsequent graphics and text commands send
  1550. their output to the newly created screen's window (until the screen is 
  1551. closed). Note that this facility is not provided by AmigaBASIC.
  1552.  
  1553. In addition, you can open user-defined windows onto any screen, in which
  1554. case all output is directed to the current output window.
  1555.  
  1556. Avoid mixing the use of default and user-defined windows. Except for the
  1557. simple case in which you use nothing but screens and their default windows
  1558. you should consider windows to be the primary output destination for
  1559. graphics and text.
  1560.  
  1561. When a screen is closed, ACE makes the screen with the next highest id 
  1562. the current one, so it is advisable to open and close screens in ascending 
  1563. and descending order.
  1564.  
  1565. A special SCREEN function exists in ACE which returns pointers to various
  1566. Intuition structures (window,screen,rastport,viewport). This is detailed
  1567. in the command and function reference (Ref.Guide) as are the following
  1568. commands:  @{"SCREEN" alink ace:docs/ref.guide/screen}, @{"SCREEN CLOSE" alink ace:docs/ref.guide/screen_close}, @{"PALETTE" alink ace:docs/ref.guide/palette} and @{"PRINTS" alink ace:docs/ref.guide/prints}.  The latter is now
  1569. redundant since all commands and functions can - as of v2.0 - be used
  1570. transparently for screens, user-defined windows and the shell/CLI.
  1571. @ENDNODE
  1572.  
  1573. @NODE 3gadgets "Gadgets"
  1574.  
  1575. Gadgets
  1576. -------
  1577. ACE supports the Amiga's three standard gadget types:
  1578. boolean, proportional (vertical and horizontal), and
  1579. string (including long integer). 
  1580.  
  1581. Since one of my aims is to support all Amigas running everything from Wb
  1582. 1.3 to Wb 3.0, I have chosen to stick with simple Intuition gadgets for
  1583. now.
  1584.  
  1585. In a future revision, a run-time test may detect machines running Wb
  1586. 2.x/3.0 and use GadTools gadgets instead. Furthermore, other gadget
  1587. types may then be supported (radio buttons, check boxes etc).
  1588.  
  1589. Memory permitting, up to 255 gadgets can be created during a single
  1590. program run.
  1591.  
  1592. The @{"GADGET" alink ace:docs/ref.guide/gadget} command creates a gadget with specific features while
  1593. @{"GADGET CLOSE" alink ace:docs/ref.guide/gadget_close} removes the gadget from the window. Once created, a gadget
  1594. can be enabled or disabled, indeed it can be disabled upon creation if
  1595. so desired.
  1596.  
  1597. Having created a gadget or gadgets, you must then decide how to receive and
  1598. handle information from them. ACE provides four methods: standard event
  1599. trapping (ON GADGET), polling (via the GADGET function), WAITing for a
  1600. specific gadget or WAITing for any gadget.
  1601.  
  1602. Where it is possible to make your programs modal (ie: focussed upon a
  1603. single event or event type) you should do so. The @{"GADGET WAIT" alink ace:docs/ref.guide/gadget_wait} command
  1604. allows this. 
  1605.  
  1606. See "@{"Event Trapping" link 3event}" for more about modality in ACE programs.
  1607.  
  1608. The following commands set up a window with two boolean gadgets and a
  1609. close gadget. The latter is set up by Intuition with the @{"WINDOW" alink ace:docs/ref.guide/window} command.
  1610.  
  1611. The program traps WINDOW and GADGET events. The comments should help you 
  1612. understand the code.
  1613.  
  1614. CONST having_fun = -1&
  1615.  
  1616. WINDOW 1,"Gadgets",(0,0)-(640,200),8
  1617.  
  1618. GADGET 1,1,"Hit Me",(3,3)-(75,20),1,1
  1619. GADGET 2,1,"Quit",(100,150)-(200,175),1,2
  1620.  
  1621. ON GADGET GOSUB gadget_handler
  1622. GADGET ON
  1623.  
  1624. ON WINDOW GOTO quit
  1625. WINDOW ON
  1626.  
  1627. '..main loop (actually does nothing, but is necessary for event trapping)
  1628. WHILE having_fun
  1629.   '..have a nap while nothing's happening 
  1630.   '..(don't hog the machine by busy waiting) 
  1631.   SLEEP        
  1632. WEND
  1633.  
  1634. gadget_handler:
  1635.   '..find out which gadget was selected
  1636.   gad = GADGET(1)
  1637.   LOCATE 12,40:PRINT "<<";gad;">>" 
  1638.   if gad = 2 then quit    
  1639. RETURN
  1640.  
  1641. quit:
  1642.   GADGET CLOSE 2
  1643.   GADGET CLOSE 1
  1644.  
  1645.   WINDOW CLOSE 1
  1646. END
  1647.  
  1648. Alternatively, you could poll for a gadget to the exclusion of other
  1649. events:
  1650.  
  1651. .
  1652. .
  1653. '..await a gadget selection
  1654. REPEAT
  1655.   WHILE NOT GADGET(0)
  1656.     SLEEP  '..be a little nice to the operating system
  1657.   WEND
  1658.   
  1659.   '..which one?
  1660.   gad = GADGET(1)
  1661.   LOCATE 12,40
  1662.   PRINT "<<";gad;">>" 
  1663. UNTIL gad=2
  1664. .
  1665. .
  1666.  
  1667. Finally, you can wait for a gadget:
  1668.  
  1669. .
  1670. .
  1671. GADGET WAIT 2      '.."GADGET WAIT 0" waits for ANY gadget! BEST method!
  1672. .
  1673. .
  1674.  
  1675. See the program prgs/misc/ACEgadgets.b for an example of gadget programming
  1676. in ACE.
  1677.  
  1678. For boolean gadgets you can - if you need to - get information about the 
  1679. width and height of the gadget's text font by calling WINDOW(12) and 
  1680. WINDOW(13). If you need more precise width information, use the graphics 
  1681. library TextLength function.
  1682.  
  1683. ACE string gadgets currently only allocate enough text buffer space for 
  1684. the number of characters which can fit into the gadget (as specified by
  1685. the bounding box in the GADGET command).
  1686.  
  1687. In the next revision, this will be changed to allow a larger buffer such
  1688. as InputBox[$] permits (see the "@{"Requesters" link 3requesters}" section) either via an
  1689. optional buffer-size parameter or a fixed-size buffer. I have not yet
  1690. decided upon the best course to take on this matter.
  1691.  
  1692. For more details about the @{"GADGET" alink ace:docs/ref.guide/gadget} commands and function, see Ref.Guide.
  1693. @ENDNODE
  1694.  
  1695. @NODE 3menus "Menus" 
  1696.  
  1697. Menus
  1698. -----
  1699. ACE supports menus ala AmigaBASIC, with two additions: menu item command
  1700. keys and a @{"MENU WAIT" alink ace:docs/ref.guide/menu_wait} command. The latter puts the program to sleep until a 
  1701. menu event occurs. The former is specified by an optional parameter to the 
  1702. @{"MENU" alink ace:docs/ref.guide/menu} command, for example:
  1703.  
  1704.     MENU 1,5,1,"Quit","Q"
  1705.  
  1706. defines menu item number 5 in menu number 1 to be the 'Quit' option and 
  1707. sets up a command-key sequence (Amiga-Q) for that item. The third parameter
  1708. enables the menu item as per AmigaBASIC.
  1709.  
  1710. Note that although ACE adjusts menu text for font size and type as set
  1711. via preferences, some fonts may require you to pad your menu title/item 
  1712. names with blanks when using command keys to avoid overlaps.
  1713.  
  1714. For an example of menu programming with ACE see prgs/@{"ifs.b" alink ace:prgs/ifs.b/main}. For a better
  1715. example, see the source code for AIDE. Over time I will modify some of 
  1716. the other example programs in the archive so that they are menu-driven.
  1717.  
  1718. See Ref.Guide for more details about the @{"MENU" alink ace:docs/ref.guide/menu} commands and function.
  1719. @ENDNODE
  1720.  
  1721. @NODE 3requesters "Requesters" 
  1722.  
  1723. Requesters
  1724. ----------
  1725. As of version 2.0, ACE supports 3 standard requesters:
  1726.  
  1727.     - System requester
  1728.     - File requester
  1729.     - Input requesters x 2
  1730.  
  1731. My recent experiences with Visual Basic for Windows have led me to add
  1732. these to ACE since I have now come to expect them. You can get the most
  1733. commonly needed requesters in a single line of ACE code!
  1734.  
  1735. If you are running Wb 2.x and above, ACE generates an ASL file requester.
  1736.  
  1737. For Wb 1.3 an ARP file requester is invoked for two simple reasons:
  1738.  
  1739.     - The arp.library is common on Wb 1.3 systems.
  1740.     - The ARP file requester is still quite good.
  1741.  
  1742. See @{"MSGBOX" alink ace:docs/ref.guide/msgbox}, @{"FILEBOX" alink ace:docs/ref.guide/filebox$}, @{"INPUTBOX" alink ace:docs/ref.guide/inputbox} and @{"INPUTBOX$" alink ace:docs/ref.guide/inputbox$} in Ref.Guide for more.
  1743. @ENDNODE
  1744.  
  1745. @NODE 3turtle "Turtle Graphics" 
  1746.     
  1747. Turtle Graphics
  1748. ---------------
  1749. You may be wondering one or more of the following:
  1750.  
  1751.     - what the heck is Turtle Graphics?
  1752.     - isn't that for kids?
  1753.     - why did he include THAT?
  1754.  
  1755. To answer the first question: Turtle Graphics (TG) originated as a subset
  1756. of the language LOGO invented by Seymour Papert et al at MIT. LOGO was
  1757. originally intended as a language for learning. Children are able to write
  1758. simple programs to draw shapes on the computer's screen or move a
  1759. Turtle - a dome-shaped robot - on a sheet of paper on the floor, learning
  1760. about geometry "by doing" and having fun to boot. 
  1761.  
  1762. LOGO also has many Lisp-like qualities and so can be used as a serious
  1763. language for AI work, although to my knowledge, it's not.
  1764.  
  1765. But I digress. Apart from the fun kids can have with TG, it's actually 
  1766. possible to construct quite complex shapes with it. Combined with
  1767. recursion, TG is a powerful tool. It is particularly useful in plotting
  1768. many fractal shapes (see @{"snowflake.b" alink ace:prgs/turtle/snowflake.b/main}, @{"dragon.b" alink ace:prgs/turtle/dragon.b/main}).
  1769.  
  1770. Since the first LOGO, there have been many manifestations of TG. Turbo
  1771. Pascal for the PC and the Mac have both had TG.
  1772.  
  1773. A couple of years ago, I  wrote a pure TG subset of LOGO which used the
  1774. same syntax as the original language and allowed recursive procedures. I've
  1775. also written TG functions in C. Both of these have been useful to me and
  1776. I've often wished that BASIC came with TG built-in. Well, now one dialect
  1777. does!
  1778.  
  1779. For some examples of the use of Turtle Graphics in ACE, see the following
  1780. programs:
  1781.  
  1782.     - @{"tree.b" alink ace:prgs/turtle/tree.b/main}
  1783.     - @{"flower.b" alink ace:prgs/turtle/flower.b/main}
  1784.     - @{"boxit.b" alink ace:prgs/turtle/boxit.b/main}
  1785.     - @{"torus.b" alink ace:prgs/turtle/torus.b/main}
  1786.     - @{"dragon.b" alink ace:prgs/turtle/dragon.b/main}
  1787.     - @{"snowflake.b" alink ace:prgs/turtle/snowflake.b/main}
  1788.     - @{"bst.b" alink ace:prgs/turtle/bst.b/main}
  1789.  
  1790. The above discussion should have answered the second question. As for 
  1791. the third, the answer is: because I wanted to!! :^)
  1792.  
  1793. Okay, enough philosophy. Here's the ACE stuff:
  1794.  
  1795. @{"BACK" alink ace:docs/ref.guide/back} n        - move turtle back by n.
  1796. @{"FORWARD" alink ace:docs/ref.guide/forward} n    - move turtle forward by n.
  1797. @{"HEADING" alink ace:docs/ref.guide/heading}     - return turtle's current heading in degrees (0..359).
  1798. @{"HOME" alink ace:docs/ref.guide/home}        - move turtle back to its home position.
  1799. @{"PENDOWN" alink ace:docs/ref.guide/pendown}        - put turtle's pen down. 
  1800. @{"PENUP" alink ace:docs/ref.guide/penup}        - lift turtle's pen up. 
  1801. @{"SETHEADING" alink ace:docs/ref.guide/setheading} degs - change turtle's heading to degs.
  1802. @{"SETXY" alink ace:docs/ref.guide/setxy} x,y    - change turtle's current x,y location.
  1803. @{"TURN" alink ace:docs/ref.guide/turn} degs    - rotate turtle by degs.
  1804. @{"TURNLEFT" alink ace:docs/ref.guide/turnleft} degs    - turn turtle left by degs.
  1805. @{"TURNRIGHT" alink ace:docs/ref.guide/turnright} degs  - turn turtle right by degs.
  1806. @{"XCOR" alink ace:docs/ref.guide/xcor}        - return turtle's current x-coordinate.
  1807. @{"YCOR" alink ace:docs/ref.guide/ycor}        - return turtle's current y-coordinate.
  1808.  
  1809. where:
  1810.     - n is pixels (x:y ratio is 2.25:1 -- assumes hi-res screen).
  1811.     - degs is a signed short integer representing degrees with
  1812.       the turtle starting at a 270 degree orientation -- pointing up).
  1813.     - home is the turtle's x,y start location (0,0).
  1814.  
  1815. Note that the X:Y ratio can be modified thus:
  1816.  
  1817.     EXTERNAL _tg_xy_ratio!
  1818.     _tg_xy_ratio = 1.125    '..1.125 is about right for a lo-res screen
  1819.  
  1820. Most LOGO environments use a coordinate system where 0,0 is at the center
  1821. of the screen and positions to the left and down of this origin are
  1822. negative while those up and to the right are positive. ACE's TG system
  1823. however, uses the Amiga's normal graphics coordinate system with 0,0 at
  1824. the top left of the screen/window so as to maintain consistency with ACE's
  1825. normal graphics commands and functions.
  1826. (eg: @{"POINT" alink ace:docs/ref.guide/point}, @{"PSET" alink ace:docs/ref.guide/pset}, @{"LINE" alink ace:docs/ref.guide/line}, @{"PAINT" alink ace:docs/ref.guide/paint}, @{"CIRCLE" alink ace:docs/ref.guide/circle},
  1827. @{"AREAFILL" alink ace:docs/ref.guide/areafill}).
  1828.   
  1829. If a negative value is specified for the turnleft or turnright commands,
  1830. the turtle will be rotated in the opposite direction to that indicated by
  1831. the the command name. Note that there is also a @{"TURN" alink ace:docs/ref.guide/turn} command.
  1832.  
  1833. When using ACE's TG system, it's best to think of an imaginary turtle (in
  1834. LOGO it's usually a small triangle on the screen) which rotates and moves
  1835. according to your whim. The turtle can either have its pen lowered or
  1836. raised - and will therefore draw or not - which is useful when you need to
  1837. move in a relative fashion from one location to another without drawing
  1838. anything.      
  1839.  
  1840. SetXY is like the graphics library Move() command and may need to be
  1841. preceded by @{"PENUP" alink ace:docs/ref.guide/penup} unless you want to draw a line.
  1842.  
  1843. To change the colour of the pen, use the @{"COLOR" alink ace:docs/ref.guide/color} command.
  1844.  
  1845. That's probably enough about Turtle Graphics. Oh, by the way, if you ever
  1846. get the chance to read Papert's "Mindstorms", do so. It's good value.
  1847.  
  1848. While I think of it, Sherry Turkle - that's Papert's wife - wrote a book
  1849. called "The Second Self: Computers and the human spirit", which I
  1850. recommend if you're at all interested in the psychological/social effects
  1851. of computing.
  1852. @ENDNODE
  1853.  
  1854. @NODE 3sound "Sound"
  1855.  
  1856. Sound
  1857. -----
  1858. ACE provides you with similar functionality as AmigaBASIC for sound
  1859. generation. It also allows you to do some things that AmigaBASIC doesn't.
  1860.  
  1861. See sound.b for an example of how to use ACE's sound facilities in general.
  1862.  
  1863. How many times have you wished that AmigaBASIC would let you produce
  1864. white noise easily like the good ol' C64 and Vic-20 did?
  1865.  
  1866. Well, you'll be pleased to know that ACE allows you to do this. All you 
  1867. have to do is allocate about 4000 or more bytes of Chip RAM (upwards of 
  1868. 4000 bytes yields better quality white noise), poke it with random values, 
  1869. (between -128 and 127) call @{"WAVE" alink ace:docs/ref.guide/wave} and you're set (see sound.b)!
  1870.  
  1871. Moreover, you can actually play sound samples (IFF or otherwise) in the
  1872. same way, using just the two commands WAVE and @{"SOUND" alink ace:docs/ref.guide/sound}. In fact, I've
  1873. written a program in ACE that plays sound samples, recognising the
  1874. IFF 8SVX format (see @{"play.b" alink ace:prgs/sound/play.b/main}). 
  1875.  
  1876. As with AmigaBASIC, a sine waveform is the default, but through the WAVE
  1877. statement you can create any waveform you wish including sawtooth,
  1878. triangle and square.
  1879.  
  1880. WAVE has the following syntaxes:
  1881.  
  1882.     WAVE voice,SIN
  1883.  
  1884. and
  1885.     
  1886.     WAVE voice,waveform-address,byte-count
  1887.  
  1888. where waveform-address is the start of a block of memory where the waveform
  1889. resides (an area of ALLOC'd CHIP memory) and byte-count is the number of
  1890. bytes in the waveform table.
  1891.  
  1892. The SOUND statement syntax is as follows:
  1893.  
  1894.     SOUND period,duration[,volume][,voice]
  1895.  
  1896. This is different to AmigaBASIC in a number of ways. First, in ACE you
  1897. specify the sampling period NOT the frequency. This was easier to implement
  1898. and still provides the same functionality, but if you want specific notes, 
  1899. you'll have to do the calculations yourself (see equations below).
  1900.  
  1901. Sampling period is inversely proportional to frequency, so a high sampling
  1902. rate corresponds to a low frequency and vice-versa. ACE allows you to
  1903. specify a sampling period in the range 124..32767.
  1904.  
  1905. The duration is a single-precision value as in AmigaBASIC but can range
  1906. from 0..999 (instead of 0..77). This range is somewhat arbitrary, but gives
  1907. plenty of scope for large sound samples. This specifies the length of time
  1908. that a tone should be played for. A duration of 18.2 corresponds to about 1
  1909. second. 
  1910.  
  1911. Volume defaults to 64 if not specified and can range from 0..64.
  1912.  
  1913. The voice can be in the range 0..3 - since there are 4 audio channels - 
  1914. with 0 & 3 corresponding to the left speaker and 1 & 2 to the right.
  1915. The default voice is 0.
  1916.  
  1917. At the moment, ACE's SOUND statement isn't very good when used to produce
  1918. a series of short pulses, although this is somewhat dependent upon the
  1919. waveform in use. In any case, more work needs to be done in this area to
  1920. prevent "popping" between SOUND statements when the audio hardware is
  1921. turned on and off in rapid sequence.
  1922.  
  1923. ACE sound is produced by programming the hardware directly. A future
  1924. version will probably utilise the audio device instead. Indeed, it's fair
  1925. to expect that SOUND in ACE will change in the future to be more in line
  1926. with AmigaBASIC.  (see also "@{"Future Versions" link 4future}").
  1927.  
  1928. Finally, here's some useful equations for use in conjunction with ACE's
  1929. SOUND statement:
  1930.  
  1931.     samples/second to period:
  1932.     ------------------------
  1933.     period = 3579546 / samples-per-second
  1934.     
  1935.     musical note to period:
  1936.     ----------------------
  1937.     period = 3579546 / (length * frequency)
  1938.  
  1939.     where length is the size of the waveform table in bytes 
  1940.     (32 bytes for ACE's sine waveform) and frequency is the
  1941.     note itself (eg: middle C is 523.25 Hz).
  1942.  
  1943.     duration value for one waveform cycle:
  1944.     -------------------------------------
  1945.     duration = .279365 * period * length / 1E6 * 18.2
  1946. @ENDNODE
  1947.  
  1948. @NODE 3event "Event trapping" 
  1949.         
  1950. Event trapping
  1951. --------------
  1952. ACE provides for AmigaBASIC-style event trapping. The following event 
  1953. types are supported:
  1954.  
  1955.     @{"BREAK" alink ace:docs/ref.guide/break}     -  user break: ctrl-c.
  1956.     @{"MOUSE" alink ace:docs/ref.guide/mouse}     -  left mouse button press.
  1957.     @{"TIMER" alink ace:docs/ref.guide/timer}(n)  -  cause a trap every n seconds.
  1958.     @{"ERROR" alink ace:docs/ref.guide/error}      -  trap file and serial I/O errors.
  1959.     @{"MENU" alink ace:docs/ref.guide/menu}      -  menu selection.
  1960.     @{"WINDOW" alink ace:docs/ref.guide/window}      -  window event: close-gadget click. 
  1961.     @{"GADGET" alink ace:docs/ref.guide/gadget}      -  user-defined gadget selection.
  1962.  
  1963. Event trapping in ACE works by checking for a given event at strategic
  1964. points in a program (before NEXT, WEND, GOTO, CALL, PRINT etc) and if an
  1965. event is detected, control is passed to a trap handling routine.  Hence,
  1966. trapping here does not refer to CPU traps (exceptions).
  1967.  
  1968. Even if your program expects to do nothing but trap events, you'll need a
  1969. loop like this:
  1970.  
  1971.     WHILE -1
  1972.       SLEEP     '..don't hog CPU time (intuiticks will be reported though)
  1973.     WEND
  1974.  
  1975. if you wish to have any events handled by your program.
  1976.  
  1977. The specification for the trapping of an event is: 
  1978.  
  1979.      ON <event> GOSUB | GOTO <label>|<line-number> (eg: ON BREAK GOTO quit)
  1980.  
  1981. which indicates the routine to which control is to be passed when an event
  1982. is trapped. This is followed at some stage by:
  1983.  
  1984.     <event> ON  (eg: BREAK ON)  
  1985.  
  1986. which causes the compiled program from that point UNTIL the trap handling
  1987. routine, to contain event trapping code.
  1988.  
  1989. It is a good idea to put trap handlers at the end of a program, since once
  1990. the handler for an event is found by the compiler, no more event trapping
  1991. code is generated for that event even if there is code below the handing
  1992. routine.  In other words, the equivalent of an <event> OFF (see below)
  1993. command is issued once the trap handling code is found by the compiler. 
  1994.  
  1995. Other commands are:
  1996.  
  1997.     <event> STOP
  1998.  
  1999. which disables trapping for the event until another <event> ON is issued, 
  2000. and:
  2001.  
  2002.     <event> OFF
  2003.  
  2004. which disables trapping for the event permanently.
  2005.  
  2006. Just so there is no misunderstanding, the latter two commands prevent the 
  2007. inclusion of event trapping code for a specific event in your program at
  2008. the assembly source level. They do this from the point in an ACE program
  2009. at which they are issued.
  2010.  
  2011. Here's a typical example:
  2012.  
  2013.     ON BREAK GOTO quit
  2014.     BREAK ON
  2015.  
  2016.     for i=1 to 1000000
  2017.      print i
  2018.     next
  2019.  
  2020.     quit:
  2021.       PRINT "**break!"
  2022.       STOP
  2023.  
  2024. Please be aware that mixing some event trapping types can have unexpected
  2025. results. More specifically, it is best to trap only one kind of event where
  2026. possible. Also, sitting in a tight loop awaiting a keypress via @{"INKEY$" alink ace:docs/ref.guide/inkey$} at
  2027. the same time as trying to trap @{"GADGET" alink ace:docs/ref.guide/gadget} events will not work very well.
  2028.  
  2029. During MENU/GADGET event trapping, WINDOW close gadget events are passed 
  2030. onto ACE's WINDOW event trapping mechanism due to the desirability of
  2031. having both enabled at once. This also holds true for MENU/GADGET WAITing
  2032. which is a far better mechanism to use wherever possible.
  2033. See "@{"Gadgets" link 3gadgets}" and "@{"Menus" link 3menus}" section above.
  2034.  
  2035. Where possible, make your program modal (ie: focussed on one event at a
  2036. time).
  2037.  
  2038. You'll have to experiment to find out what works well together and what 
  2039. doesn't.
  2040.  
  2041. Don't forget though, that you can quite easily have N different kinds of 
  2042. event trapping in one program, and use <event> ON|OFF|STOP to control
  2043. which events are currently being paid attention to and which are not.
  2044. @ENDNODE
  2045.  
  2046. @NODE 3error "Error Handling" 
  2047.  
  2048. Error Handling
  2049. --------------
  2050. The compiler messages generated by ACE are often different to the ones in
  2051. the AmigaBASIC interpreter (and ACE doesn't beep at you with each error)
  2052. but they are usually fairly clear.
  2053.  
  2054. Syntactically incorrect programs can lead ACE to produce a bunch of
  2055. spurious error messages. In such cases, it's best to ignore all but the
  2056. first one or two, unless there are "clusters" of messages which are
  2057. separated by periods of error-free compilation.
  2058.  
  2059. If you leave out END IF, WEND, UNTIL, NEXT, END SUB, END STRUCT or
  2060. END CASE, there will be a corresponding number of error messages at
  2061. the end of the compile. If you leave off two WENDs, you'll get 2
  2062. "WHILE without WEND" error messages.
  2063.  
  2064. ACE generally reports the first error in a line of code and ignores the
  2065. rest of the "bad" line. A typical message consists of the line containing
  2066. the error, a carat ("^") marker, and the error message itself. More work
  2067. still needs to be done on ACE's compile-time error handling, but it's
  2068. bearable.
  2069.  
  2070. No error messages are issued by ACE programs at run-time. Generally, when
  2071. a program runs into something it can't do, or an erroneous request - like
  2072. trying to open two files to the same file number or trying to open a
  2073. library that doesn't exist - the program will either quit or just not have
  2074. the desired effect. 
  2075.  
  2076. Note that while the @{"ERR" alink ace:docs/ref.guide/err} function and ON @{"ERROR" alink ace:docs/ref.guide/error} event trapping are supported,
  2077. only file and serial I/O errors are currently reported via these
  2078. mechanisms.
  2079. @ENDNODE
  2080.  
  2081. @NODE 4asm "Notes for assembly programmers" 
  2082.  
  2083. Notes for assembly programmers
  2084. ------------------------------
  2085. I've tried to make the assembly source files that ACE produces as 
  2086. readable as possible by using meaningful data object names. See also
  2087. "@{"Compiler options" link 2options}" re: the compiler's "c" switch.
  2088.  
  2089. Linked library routines use data registers d0-d6 and address registers 
  2090. a0-a3, while d7 is used for array index calculations. Also, a4 and a5 are 
  2091. used as stack frame pointers for variables and parameters.
  2092.  
  2093. Most db.lib routines don't save and restore registers via the stack, but 
  2094. the use of registers is internally consistent (ie: all registers are up
  2095. for grabs but interdependent routines are written in such a way so as not
  2096. to conflict).
  2097.  
  2098. The use of linked libraries means that the size of all executables is
  2099. fairly large. But given that disk space and memory are cheap, I'd rather
  2100. this than the alternative of having every executable be dependent upon one
  2101. or more special shared libraries at run-time. However, I will try to reduce
  2102. the size of executables.
  2103.  
  2104. Due to BASIC's tendancy to coerce data types so much for the programmer,
  2105. the resulting code can look a little nasty, and big increases in
  2106. efficiency can be gained by careful combinations of data types in
  2107. expressions.
  2108.  
  2109. Writing ACE has so far been a learning experience for me and if when I
  2110. started, I knew what I know now, I would have done many things differently.
  2111.  
  2112. My original rationale for passing parameters via registers to ACE
  2113. (and shared)  library functions was to improve execution speed. However,
  2114. since I call lots of other functions (eg: in ami.lib) which require their
  2115. parameters to be on the stack, I would probably call ALL functions in this
  2116. way if I did it again.  Oh well.
  2117.  
  2118. Moreover, my desire for internal consistency led me to a rather odd method
  2119. of passing parameters to SUBs. This allowed me to treat parameters in the
  2120. same way as variables which is all very nice, but it led to other problems,
  2121. chief among them being the need to use a Forbid()/Permit() pair when
  2122. sending parameters to a SUB. This works fine however, so I'm taking the
  2123. view that if it 'aint broke, I probably shouldn't fix it. 
  2124. @ENDNODE
  2125.  
  2126. @NODE 4limit "Limitations" 
  2127.  
  2128. Limitations
  2129. -----------
  2130. Variables do NOT get a default zero or NULL value, so don't assume ANYTHING
  2131. about the contents of an uninitialised variable. For example: @{"PRINT" alink ace:docs/ref.guide/print} X will
  2132. yield garbage if X has not been given a value. The optional variable 
  2133. declarations provided in ACE are therefore worth using since they DO give
  2134. variables an initial zero or NULL value.
  2135.  
  2136. The precision of exponentiation begins to falter with large numbers because
  2137. all exponentiation is currently done with the single-precision math
  2138. library function SPPow().
  2139.  
  2140. While strings can be defined to be longer (or shorter) than 1K, there
  2141. are some ACE commands and functions which still assume a 1K limit, namely: 
  2142. @{"STRING$" alink ace:docs/ref.guide/string$}, @{"SPACE$" alink ace:docs/ref.guide/space$}, @{"LINE INPUT#" alink ace:docs/ref.guide/line_input}, @{"INPUT" alink ace:docs/ref.guide/input} and @{"SWAP" alink ace:docs/ref.guide/swap}.
  2143.  
  2144. Strings and arrays which are local to a subprogram will be overwritten
  2145. if the @{"SUB" alink ace:docs/ref.guide/sub..end_sub} has recursive calls to itself. The same applies to string
  2146. parameters.  In all these cases a single static data item is being
  2147. referenced.
  2148.    
  2149. If you issue RETURN from within a @{"FOR" alink ace:docs/ref.guide/for..next} loop, the return address will *not*
  2150. be the top item on the stack. Instead, FOR..NEXT loop data will be. A GURU
  2151. will almost certainly result. It is probably better to use a while or
  2152. repeat loop if you must RETURN from within a loop.
  2153. See also @{"EXIT FOR" alink ace:docs/ref.guide/exit_for} in Ref.Guide which allows for the safe, early termination
  2154. of FOR loops.
  2155.  
  2156. A shared variable cannot be used as a FOR loop index in ACE. Any attempt to
  2157. do so will result in a compilation error.
  2158.  
  2159. @{"IF..THEN" alink ace:docs/ref.guide/if} NEXT will not have the desired effect (it's bad coding anyway).
  2160. NEXT must always appear on a line by itself or as part of a multi-
  2161. statement. 
  2162.  
  2163. Expressions and parameter lists cannot currently be split over more than 
  2164. one line.
  2165.  
  2166. The compiler only responds to ctrl-c during the main compilation phase, 
  2167. and not during optimisation or when target code is being written.
  2168.  
  2169. Don't mix the compiler's "b" option with @{"BREAK" alink ace:docs/ref.guide/break} event trapping, as they will
  2170. conflict.
  2171. @ENDNODE
  2172.  
  2173. @NODE 4bugs "Known Bugs" 
  2174.  
  2175. Known Bugs
  2176. ---------- 
  2177. The @{"SAY" alink ace:docs/ref.guide/say}(n) *function* works under release 2.x but not under 1.3. Since the 
  2178. function uses no 2.x-specific code, this is puzzling. The SAY command
  2179. works under both 1.3 and 2.x however.
  2180.  
  2181. A68K sometimes complains about string literal definitions produced by ACE 
  2182. if they are much longer than a single line.
  2183.  
  2184. Some fonts cause the INPUTBOX[$] display (string gadget) to be corrupted. 
  2185. Stick to topaz for this where possible. A future revision will use a 
  2186. GadTools requester (for 2.x machines).
  2187. @ENDNODE
  2188.  
  2189. @NODE 4future "Future versions" 
  2190.  
  2191. Future versions
  2192. ---------------
  2193. Random files and double-precision floating-point math are high on the
  2194. agenda.
  2195.  
  2196. More graphics (eg: GET,PUT) commands and functions are planned and I also 
  2197. intend to fix any remaining differences between ACE and AmigaBASIC in this 
  2198. area. 
  2199.  
  2200. Commands for IFF sound and picture file playing/viewing are likely.
  2201.  
  2202. I may provide support for sprites at some stage. 
  2203.  
  2204. AGA screen modes are likely to be supported sometime.
  2205.  
  2206. Thus far, I've taken the approach of implementing what I most often use 
  2207. and what I have often wished for in BASIC.
  2208.  
  2209. In recent times I have been impressed by three things in the programming 
  2210. world: the rise of Object-Oriented Programming (OOP), Resources (as found
  2211. on the Macintosh and Windows) and Visual BASIC for Windows.
  2212.  
  2213. The idea of resources (pioneered by the Macintosh resource fork and
  2214. ResEdit) is a powerful one and Microsoft and Borland have picked up 
  2215. on this in Windows. I wish the Amiga had them as standard, but alas it 
  2216. doesn't. Still, the emergence of GUI building tools in the Amiga world 
  2217. has gone some way toward making up for this.
  2218.  
  2219. I am trying to add more "visual" stuff to ACE, hence: gadgets, menus,
  2220. requesters, AIDE. You can expect to see more "visualising" of ACE as time
  2221. goes by, including a GUI designer written in ACE for ACE programs. To make 
  2222. ACE like Visual BASIC would take a major rewrite, but I can at least try
  2223. to take advantage of some of its features and concepts.
  2224.  
  2225. I have no firm plans to include OOP capabilities in ACE, but one never
  2226. knows. 
  2227.  
  2228. There is some possibility of ACE taking on board some of the
  2229. list-processing features of certain functional programming languages
  2230. (eg: Lisp, LOGO).
  2231. @ENDNODE
  2232.  
  2233. @NODE 4pd "A note to PD libraries and reviewers"
  2234.  
  2235. A note to PD libraries and reviewers
  2236. ------------------------------------
  2237. I'd appreciate it if you would check with me (if possible) to ensure you
  2238. have the latest version of ACE before including it in your library or
  2239. reviewing it for a magazine. If you don't have e-mail access, I don't
  2240. expect you to do this (snail-mail is a pain isn't it!?).
  2241.  
  2242. Also, to those magazines who have reviewed ACE so far, let me say a big 
  2243. THANK YOU. Good publicity is always appreciated as is acknowledgement of 
  2244. the time I've spent on ACE. I hope I accept criticism with as much grace.
  2245.    
  2246. Lastly, the wider ACE travels the happier I am, so I'm pleased to see
  2247. ACE turning up in the odd PD library. Please note however that I don't
  2248. wish people to profit financially from the distribution of ACE. You may
  2249. charge a fee which covers the cost of the disk and the copying thereof,
  2250. but no more.
  2251. @ENDNODE
  2252.  
  2253. @NODE 4disclaim "Disclaimer" 
  2254.  
  2255. Disclaimer
  2256. ----------
  2257. Although every care has been taken in the development and testing of the 
  2258. compiler and its libraries, the author will not be liable for damages
  2259. caused either directly or indirectly as a result of the use of ACE.
  2260. @ENDNODE
  2261.  
  2262. @NODE 4refer "References" 
  2263.  
  2264. References
  2265. ----------
  2266. The following references have been used throughout the development of ACE:
  2267.  
  2268. +-------------------------------------------------------------------------+
  2269. | "Amiga BASIC" (manual), 1985, Commodore-Amiga Inc. and Microsoft Inc.   |
  2270. |                                      |
  2271. | "Amiga ROM Kernel Reference Manual: Libraries and Devices", Commodore-  |
  2272. |  Amiga                                                                  |
  2273. |                                      |
  2274. |  Anderson & Thompson, 1990, "Mapping the Amiga", COMPUTE! Publications  |
  2275. |  Inc.                                                                   |
  2276. |                                      |
  2277. |  Bleek, Jenrich & Schulz, 1989, "Amiga C for Advanced Programmers",     |
  2278. |  Abacus                                                                 |
  2279. |                                      |
  2280. |  Bleek, Jenrich & Schulz, 1989, "Advanced System Programmers Guide",    |
  2281. |  Abacus                                                                 |
  2282. |                                      |
  2283. |  Choi, 1990, "Advanced Programming Techniques", University of Tasmania  |
  2284. |                                      |
  2285. |  Commander, 1987, "Amiga Assembly Language Programming", TAB Books Inc. |
  2286. |                                      |
  2287. |  Dittrich, 1989, "Amiga Machine Language", Abacus              |
  2288. |                                      |
  2289. |  Schaun, 1990, "Amiga C for Beginners", Abacus              |
  2290. +-------------------------------------------------------------------------+
  2291.  
  2292. The most frequently used of these has been "Mapping the Amiga". Despite 
  2293. its not infrequent errors, it remains an excellent resource. I have
  2294. also often referenced the Advanced Amiga C programming book by Bleek et al.
  2295.   
  2296. Although not listed, Commodore's Autodocs for the Amiga (supplied with the
  2297. Native Developer Kit) are also constantly used.
  2298.  
  2299. Young Choi's Advanced Programming notes in many ways provided the impetus
  2300. for the development of ACE. They were used in a compiler construction
  2301. course I took as an undergraduate. I thank Young for introducing me to
  2302. the joys of compiler writing, although I know he didn't intend me to
  2303. spend *all* my time writing compilers. :-)
  2304.  
  2305. Including the Pascal Minus compiler I wrote for that course, and the BASIC 
  2306. interpreter I wrote during the same period, I've since written a version of
  2307. Logo (turtle graphics subset), a Forth interpreter and ACE.
  2308. @ENDNODE
  2309.  
  2310. @NODE 4final "Final word" 
  2311.  
  2312. Final word
  2313. ---------- 
  2314. Let me offer my thanks to Charlie Gibbs for his reliable assembler and to 
  2315. the Software Distillery for Blink. Without these excellent programs, far 
  2316. fewer compilers would have seen the light of day, including ACE.
  2317.  
  2318. Sozobon C (ZC) has always been a reliable workhorse for me, so a vote of
  2319. thanks goes to Sozobon as well. Isn't PD great?
  2320.  
  2321. I'd like to thank those people who have tested ACE so far:
  2322. Addison Laurent, Byron Montgomerie, Juergen Weinelt, Alan Peyton-Smith,
  2323. Michael Zielinski, Ken Thompson, Peter Zielinski and others.
  2324.  
  2325. These guys have given ACE a good workout on a variety of platforms ranging 
  2326. from an A1000 running Wb 1.3 to 68030 machines running Wb 3.0. They have 
  2327. all pointed out a number of bugs/problems to me which have either been
  2328. fixed or put on the list of things to fix.
  2329.  
  2330. I'd especially like to thank Michael Zielinski for discovering a
  2331. particularly serious bug which prevented branches of greater than 32K in
  2332. length prior to v1.02.  Also, Enforcer hits reported by him started me on
  2333. a trail which led to a nasty string-related bug.
  2334. (see entry for 13/4/93 in docs/history).
  2335.  
  2336. Jarto 'Robin' Tarp pointed out how inefficient my first implementation
  2337. of INSTR was. It's considerably faster now (v1.02).
  2338.  
  2339. Let me stress that any remaining bugs in ACE are entirely my fault.
  2340.  
  2341. Many others have given me a great deal of encouragement and made useful 
  2342. comments throughout 1993. I hope this continues.
  2343.  
  2344. I'd also like to thank my wife Karen, for her encouragement and support 
  2345. and for putting up with the number of hours I spend at the computer. IFS
  2346. is her favourite program (see the "Green Fern") so it's dedicated to her.
  2347.  
  2348. Despite ACE's problems (see "@{"Limitations" link 4limit}" and "@{"Known Bugs" link 4bugs}") it is already 
  2349. proving to be a useful tool for me, and if others can derive benefit from
  2350. it, well, that's great. ACE is gradually coming to support the major
  2351. features I want it to, but there's still plenty of work to do.
  2352.  
  2353. The provision of calls to shared library functions, external functions, 
  2354. machine code routines, inline assembly code, and include files should 
  2355. go a long way towards making up for ACE's intrinsic shortcomings.
  2356.   
  2357. I hope you enjoy ACE and find it useful. I'm learning a great deal by 
  2358. developing it and having a lot of fun in the process, so I'm not after 
  2359. monetary rewards. Of course, please feel free to donate if you wish!
  2360.  
  2361. What I DO want is feedback. If you have any problems, requests, queries or 
  2362. suggestions, I want to hear from you and I'd like to hear about
  2363. interesting programs you've written with ACE.
  2364. (send me the source if you like!).
  2365.  
  2366. Obviously I want to know about bugs too. 
  2367.  
  2368. Remember that ACE is FreeWare, so redirect flames to /dev/null.
  2369. (ie: be nice).
  2370.  
  2371. Happy ACEing!
  2372.  
  2373. Regards, David Benn
  2374. 19th January 1994
  2375.  
  2376. +-----------------------------------------------+
  2377. |     Internet: dbenn@leven.appcomp.utas.edu.au |
  2378. |                        |
  2379. |   Compuserve: 100033,605                  |
  2380. |                        |
  2381. | Discovery 40: 032432850            |
  2382. |                              |
  2383. |      Phone: (003) 317 680 [home]              |
  2384. |          (003) 243 285 [work]              |
  2385. |                              |
  2386. |    Address: 181 St John Street, Launceston,     |               
  2387. |          Tasmania, Australia, 7250              |
  2388. +-----------------------------------------------+
  2389. @ENDNODE
  2390.