home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff297.lzh / DevKit / DevKit.doc < prev    next >
Text File  |  1989-12-29  |  45KB  |  935 lines

  1.      DevKit - Release 1.2 - August 29, 1989
  2.  
  3.      DevKit files and programs copyright (c) 1989, Peter Cherna.  See below
  4.      for distribution restrictions.
  5.  
  6.      Contents
  7.  
  8.      1.0  Introduction
  9.           1.1  Copyright and Distribution Notices
  10.           1.2  Disclaimers
  11.           1.3  Contents of the DevKit
  12.           1.4  Considerations for Use
  13.      2.0  ARexx Scripts
  14.           2.1.1     Compile.ced
  15.           2.1.2     Compile.WShell.ced
  16.           2.2  NextError.ced
  17.           2.3  LookUp.ced
  18.           2.4  LookUpHeader.ced
  19.           2.5  LookUpTag.ced
  20.           2.6  BlockSearch.ced
  21.           2.7  SetScriptBit.ced
  22.           2.8  CommentBlock.ced
  23.           2.9  UncommentBlock.ced
  24.           2.10 ARexx Notes
  25.           2.11 CygnusEd Notes
  26.      3.0  Shell/CLI Scripts and Other S Directory Stuff
  27.           3.1  SetSource
  28.           3.2  MakeTags
  29.           3.3  RexxCommands
  30.      4.0  Executable Programs
  31.           4.1  WBTF
  32.           4.2  GetAutoDoc
  33.           4.3  MakeAutoDocIndex
  34.           4.4  MakeHeaderIndex
  35.           4.5  GenTags
  36.      5.0  C Language Sources
  37.      6.0  Conclusion
  38.      7.0  Future Avenues
  39.  
  40.  
  41. 1.0  Introduction
  42.  
  43.      What is the DevKit?  The DevKit is a collection of C and ARexx
  44.      language programs to facilitate the life of the software developer. 
  45.      With the DevKit, you can launch your compiler from within your editor,
  46.      have the cursor positioned on your errors, look up the autodoc page
  47.      for any Amiga function at a single keystroke, find a system structure
  48.      or #define within the include files, or find any function in the
  49.      source code you are developing.  As well, it provides a utility where
  50.      you can put the compiler options in the source code for easy reference
  51.      and modification.
  52.  
  53.      The compiling and error-finding functions are designed to work with
  54.      CygnusEd Professional and Manx C 3.6a.  You also gain a slight
  55.      advantage if you own WShell.  A dedicated worker could adapt these to
  56.      other compilers or ARexx-compatible editors.  The autodoc lookup works
  57.      from the CLI as well, and is useful to anyone possessing the 1.3
  58.      Native Developer's Kit from Commodore, containing the autodoc and
  59.      include files.
  60.  
  61.      1.1  Copyright and Distribution Notices                               
  62.  
  63.      The files and programs that make up the DevKit are Copyright (c) 1989,
  64.      Peter Cherna, and are freely redistributable with the following
  65.      conditions:
  66.  
  67.           1.   All the files and programs that make up the DevKit shall be
  68.                kept together in unmodified form.
  69.  
  70.           2.   Any modified files may be added to the DevKit provided they
  71.                are in a separate directory for modified files, and clearly
  72.                marked as being modified (by whom, when, and for what
  73.                purpose).  The original unmodified files must still remain
  74.                as they were in the DevKit.  Any such modified files must
  75.                have no further restrictions on distribution than those
  76.                restrictions given here for the DevKit.
  77.  
  78.           3.   The DevKit may be not be distributed for profit.  Only a
  79.                nominal charge may be associated with its distribution.
  80.  
  81.           4.   The DevKit may not be distributed along with any commercial
  82.                product without prior consent from the author of the DevKit.
  83.  
  84.  
  85.      1.2  Disclaimers
  86.  
  87.           The DevKit is provided as is, without warranty of any kind.  You
  88.           assume full risk of its use.  So there, but don't let that scare
  89.           you.
  90.  
  91.           I am in no way affiliated with Manx, William Hawes, or
  92.           ASDG/CygnusSoft, other than being a happy user of their products. 
  93.           The DevKit works with products from these developers because
  94.           those products were appropriate for the need at hand.
  95.  
  96.           The DevKit software and documentation is my own and in no way
  97.           expresses any opinions of, recommendations of, or guarantees on
  98.           the part of my employer.
  99.  
  100.  
  101.      1.3  Contents of the DevKit
  102.  
  103.  
  104.           DevKit.doc               This documentation file.
  105.           Rexx (dir)               Directory containing ARexx scripts for
  106.                                    CygnusEd Professional.
  107.                Compile.ced         Launch compiler from within editor.
  108.                Compile.WShell.ced  Launch compiler from within editor, for
  109.                                    WShell users.
  110.                NextError.ced       Find next Aztec C error.
  111.                LookUp.ced          Look up a system function in the
  112.                                    autodocs.
  113.                LookUpHeader.ced    Look up a #define'd constant or
  114.                                    structure in the header files.
  115.                LookUpTag.ced       Look up a function within your source
  116.                                    code.
  117.                BlockSearch.ced     Search for marked region.
  118.                SetScriptBit.ced    Sets the script bit of the current file.
  119.                CommentBlock.ced    Comments out the marked section of code. 
  120.                                    Handles the fact that in C, comments do
  121.                                    not nest.
  122.                UncommentBlock.ced  Uncomments a block that was commented
  123.                                    out using CommentBlock.ced.
  124.           s (dir)
  125.                SetSource           Shell/CLI script that allows you to use
  126.                                    an environment variable to specify your
  127.                                    source directory.
  128.                MakeTags            Generates tags from multiple source
  129.                                    files, for later use by LookUpTag.ced.
  130.                RexxCommands        Configuration file for CygnusEd
  131.                                    Professional that binds the DevKit ARexx
  132.                                    functions to function keys.
  133.           c (dir)
  134.                GetAutoDoc          Extracts an autodoc for the specified
  135.                                    function.
  136.                MakeAutoDocIndex    Builds the index files for the autodocs.
  137.                MakeHeaderIndex     Builds the index files for the compiler
  138.                                    headers.
  139.                WBTF                Utility that brings the Workbench to the
  140.                                    front.
  141.                GenTags             Generate tags for a single source file.
  142.           Sources (dir)            Source code for the above modules.
  143.                GetAutoDoc.c
  144.                MakeAutoDocIndex.c
  145.                MakeHeaderIndex.c
  146.                WBTF.c
  147.                GenTags.c
  148.           Examples (dir)
  149.                AutoCommands        Some "Auto:" commands to illustrate the
  150.                                    use of Compile.ced.
  151.  
  152.      1.4  Considerations for Use
  153.  
  154.      The DevKit was designed for relatively well-equipped Amigas, i.e. hard
  155.      disks and extra memory.  There is no reason why it shouldn't work on a
  156.      1 Meg floppy-based system, but it may be difficult to have CygnusEd,
  157.      ARexx, and the Aztec C compiler all running in 512K.  The lookup
  158.      functions depend on having the autodocs or compiler headers plus some
  159.      special index files available.  The AutoDocs take about 710K, plus
  160.      about 55K for the index files.  The compiler headers take about 435K,
  161.      plus about 100K for the index files.  For convenience, it is desirable
  162.      that they be kept on a hard disk, but they will work quite well (and
  163.      reasonably fast) if kept on a floppy disk.
  164.  
  165.  
  166. 2.0  ARexx Scripts
  167.  
  168.      Nine ARexx scripts can be found in the Rexx directory of the DevKit. 
  169.      These scripts are designed to work from CygnusEd Professional, a high-
  170.      performance editor available from ASDG Inc.  Several of the scripts
  171.      work in conjunction with the Aztec C compiler from Manx Systems. 
  172.      These scripts are designed to take advantage of ARexx version 1.10. 
  173.      If you have an earlier version, you should definitely upgrade to the
  174.      latest version, at least 1.10.
  175.  
  176.  
  177.      2.1.1 Compile.ced
  178.  
  179.      Compile.ced is an ARexx program designed to work with CygnusEd
  180.      Professional.  It is used to launch a compiler (usually to compile the
  181.      file that you are currently editing).  It could easily be adapted to
  182.      other programs that depend on a text file for input.
  183.  
  184.      In the file you are editing, you must place a comment that tells
  185.      Compile.ced what to do with your file.  You want to provide
  186.      Compile.ced with a series of commands to perform, typically compiling
  187.      and linking your file.  Near the beginning of your source code, for
  188.      each command that is to be executed by Compile.ced you must include
  189.      the word "Auto:" followed by the desired command.  The command may
  190.      include the special wildcards <path> and <file>, which stand for the
  191.      path to your file and the file name (less its extension, usually
  192.      ".c").  To illustrate, if your file was "DH0:Sources/MyStuff.c", and
  193.      you wished to compile and link it under Aztec C (with standard
  194.      options, and sending the .o file to the RAM: disk), you would put the
  195.      following in a comment near the beginning of your code.
  196.  
  197.           Auto: cc -o ram:<file>.o <path><file>
  198.           Auto: ln ram:<file>.o -lc -o <path><file>
  199.  
  200.      Compile.ced will find these commands, substitute the string
  201.      "DH0:Sources/" for each occurrence of the string <path> and substitute
  202.      the string "MyStuff" for each occurrence of the string <file>, and
  203.      will execute the resulting commands:
  204.  
  205.           cc -o ram:MyStuff.o DH0:Sources/MyStuff
  206.           ln ram:MyStuff.o -lc -o DH0:Sources/MyStuff
  207.  
  208.      Compile.ced expects to find the first occurrence of "Auto:" within the
  209.      first thirty lines of your source code, and will continue processing
  210.      until a line without an "Auto:" is found.  This means that all the
  211.      "Auto:" commands must be on consecutive lines (no skipping allowed). 
  212.      You must use "Auto:" as written because case matters, so don't use
  213.      "AUTO:" or "auto:".
  214.  
  215.      (You probably will want to make use of Compile.ced and NextError.ced's
  216.      ability to tell you where the errors your compiler found are.  To do
  217.      so, you should use option -q of Aztec's cc compiler, which sends error
  218.      messages (but not warnings) to a file called "AztecC.err" in the
  219.      current directory.)
  220.  
  221.      If you install Compile.ced on a CygnusEd function key (say F1) by
  222.      setting its command to be "run rx Compile.ced", you will be able to
  223.      continue editing another file during compilation.  When you press F1,
  224.      Compile.ced checks to see if the file has been modified since the last
  225.      save, and asks you if you wish to save before compiling.  Select "Yes"
  226.      to save, or "No Way!" to compile without saving.  Once the Workbench
  227.      screen pops up, and Compile.ced announces that it is scanning your
  228.      file, you are free to continue editing this or other files.
  229.  
  230.      Compile.ced then looks for "Auto:" commands in your file.  If none are
  231.      found, you will be informed of the problem.  Otherwise, Compile.ced
  232.      executes performs the substitutions for <path> and <file>, and then
  233.      executes the "Auto:" command.
  234.  
  235.      If the compiler failed because there were errors in your source, then
  236.      Compile.ced will recognize that (by looking for the file AztecC.err). 
  237.      It will invoke the ARexx program NextError.ced (see below), which will
  238.      locate and display the errors the compiler found in your source.
  239.  
  240.      If there are no compilation errors, you will be told so, and you then
  241.      have the choice of returning to the Workbench screen (to test your
  242.      code) or staying with the editor.
  243.  
  244.      Unfortunately, Compile.ced has no way of catching "Auto:" commands
  245.      that fail, other than when Aztec's compiler detects errors and creates
  246.      the AztecC.err file.  As a result, being told that there were no
  247.      compiler errors doesn't guarantee that the linker didn't fail, for
  248.      example.  If you use WShell, this problem can be overcome by using the
  249.      Compile.WShell.ced ARexx script in place.
  250.  
  251.      The advantages of having "Auto:" commands are obvious.  The
  252.      instructions on how to compile a program remain with the program's
  253.      source itself.  If you decide to change a compiler option, you just
  254.      modify the "Auto:" line in your source (if you want debugging
  255.      information for Aztec SDB, just add option -n to the compiler line,
  256.      and -g to the linker line, press F1, and voila!)  If you need to link
  257.      with the math library, you say so right in your source code.  Because
  258.      of the substitution for <path> and <file>, you can safely move your
  259.      source code to a new directory and it will compile from there as well.
  260.  
  261.      Compile.ced does not provide any dependency analysis in the style of
  262.      make.  Of course, nothing stops you from using make as your "Auto:"
  263.      command, as in
  264.  
  265.           Auto: make <file>
  266.  
  267.      Note that any DOS command is ok as an "Auto:" command.
  268.  
  269.      All the files in the Sources directory of the DevKit were compiled via
  270.      Compile.ced.  You can look at how those files are set up to get some
  271.      ideas on how to proceed.  For some other example "Auto:" commands, see
  272.      the file AutoCommands in the Examples directory of the DevKit.
  273.  
  274.  
  275.      2.1.2 Compile.WShell.ced
  276.  
  277.      Compile.WShell.ced is an ARexx program that is very similar to
  278.      Compile.ced described above.  It does everything that Compile.ced does
  279.      but takes advantage of an extra feature currently offered only by
  280.      WShell, which allows an ARexx program to tell the success or failure
  281.      of a DOS command it executed.  This includes the "Auto:" commands.  If
  282.      you own WShell, you should use this ARexx program in place of
  283.      Compile.ced.  Compile.WShell.ced will inform you of exactly which
  284.      "Auto:" command failed, and will stop processing further "Auto:"
  285.      commands.  This is useful if, for example, you pressed control-C
  286.      during compiling, or if the linker failed to resolve all references.
  287.  
  288.  
  289.      2.2  NextError.ced
  290.  
  291.      NextError.ced is an ARexx program designed to work with CygnusEd
  292.      Professional and Aztec C which takes the AztecC.err error file
  293.      generated by the Aztec compiler and locates the errors within your
  294.      source.  The cursor of the editor will be placed on the error, and a
  295.      requester will appear giving the error message.
  296.  
  297.      If you install NextError.ced on the F2 function key in CygnusEd, you
  298.      can always get the next error by pressing F2.  Compile.ced launches
  299.      NextError.ced when it detects compiler errors, so your errors appear
  300.      automatically after compiling.
  301.  
  302.      NextError.ced finds out which source file contains the next error (it
  303.      could be in something you've #include'd.)  If you don't have that file
  304.      currently displayed in CygnusEd, you will be told that there is an
  305.      error in that file and what the error is, and then you will be asked
  306.      if you want it loaded into CygnusEd.  If you say yes, it will be
  307.      brought in.  If you say no, then that error will be skipped.  If the
  308.      file with the error is already displayed in CygnusEd (or has just been
  309.      brought in at your request), then the cursor will be moved onto the
  310.      error, and a requester will appear giving the name of the file, the
  311.      line in the source, the error number, and the error message.  You will
  312.      be asked if you wish to go to the next error or not.  If you say yes,
  313.      then the next error will be found.  If you say no, you will be able to
  314.      edit.  Later, you can get the next error by calling NextError.ced
  315.      (press F2).
  316.  
  317.      When there are no more errors, NextError.ced will tell you so.  If you
  318.      then call NextError.ced again, the first error will be redisplayed,
  319.      and on from there.
  320.  
  321.      When NextError.ced tries to place the cursor on your error, there are
  322.      a few things that must be remembered.  First, the compiler is only so
  323.      good at figuring out where the error really is.  A missing semicolon,
  324.      for example, is usually flagged at the beginning of the next line. 
  325.      Second, if you have changed your file since you compiled it (say by
  326.      fixing an earlier error), and this has meant changing the number of
  327.      lines before the error, then the cursor will miss the error by that
  328.      number of lines.  Likewise, if you've modified the line that contains
  329.      the error, the cursor may miss the error by a number of characters. 
  330.      Finally, and this is important, NextError.ced can account for tab
  331.      characters only under certain conditions.  You must be using a fixed
  332.      tab size (any tab size is ok) and not custom tabs.  Second, all the
  333.      tabs had better be at the beginning of the line.  If your line has
  334.      embedded tabs, such as
  335.  
  336.           foo(...);<TAB>bar(...);
  337.  
  338.      and the compiler finds fault with the parameters of bar(),
  339.      NextError.ced will land the cursor slightly over from where it should
  340.      be.  More insidious is a line with a hidden space, say
  341.  
  342.           <SPACE><TAB>foo(...);
  343.  
  344.      which looks exactly like
  345.  
  346.           <TAB>foo();
  347.  
  348.      The line with the hidden space will cause NextError.ced to misplace
  349.      the cursor a bit.
  350.  
  351.  
  352.      2.3  LookUp.ced
  353.  
  354.      This is an ARexx program designed to work with CygnusEd Professional. 
  355.      The word under your cursor (or immediately to the left of your cursor)
  356.      will be taken as the name of the Amiga system function you wish to
  357.      look up in the autodocs.  This is done by invoking the program
  358.      GetAutoDoc (see later discussion for its stand-alone use).  Note that
  359.      you must have assigned the label "AutoDocs:" to the directory
  360.      containing your autodoc files (or placed your autodoc files on a disk
  361.      called "AutoDocs"), and you must have run MakeAutoDocIndex to build
  362.      the indexes that GetAutoDoc needs to find autodoc entries efficiently.
  363.  
  364.      LookUp.ced identifies the word in your text by looking for all
  365.      adjoining alphanumeric characters (as well as the underscore symbol
  366.      "_").  If CygnusEd's cursor is on a character in a word or on the
  367.      character immediately after the word (i.e. it's ok if your cursor is
  368.      on the open bracket following the function), LookUp.ced will attempt
  369.      to find a function by that name in the autodocs.  If your cursor is
  370.      not on a word, a string requester will appear, into which you may type
  371.      the name of the function to look up.  If no autodoc is found for the
  372.      word you desire, you will be told.
  373.  
  374.      When an autodoc is found, LookUp.ced will open a new view in CygnusEd
  375.      and put the autodoc for the requested function in that view.  If you
  376.      already have a view in CygnusEd that was opened by LookUp.ced or
  377.      LookUpHeader.ced (see below), and its contents haven't been modified,
  378.      then LookUp.ced (like LookUpHeader.ced) will use this view rather than
  379.      opening yet another one.  This helps prevent excessive clutter of the
  380.      CygnusEd window/screen.
  381.  
  382.      Like NextError.ced (above), and LookUpHeader.ced (below), Lookup.ced
  383.      can get a bit lost if you are using custom tabs, or if you have
  384.      embedded tabs.  Tabs of any fixed size, so long as they are at the
  385.      beginning of the line, are ok.
  386.  
  387.  
  388.      2.4  LookUpHeader.ced
  389.  
  390.      Similar to LookUp.ced, LookUpHeader.ced is an ARexx program designed
  391.      to work with CygnusEd Professional and the compiler headers files. 
  392.      The word under your cursor (or immediately to the left of your cursor)
  393.      will be taken as the name of the Amiga system structure or #define'd
  394.      constant that you wish to look up in the compiler headers.  If your
  395.      cursor is not on a word, a string requester will appear, into which
  396.      you can type the name of the structure or constant you want to look
  397.      up.  Note that you must have assigned "ch:" to the directory
  398.      containing your compiler headers (or placed your compiler headers on a
  399.      disk named "ch"), and you must have run MakeHeaderIndex to build the
  400.      indexes that LookUpHeader.ced needs to find system structures and
  401.      constants efficiently.
  402.  
  403.      If the system structure or constant is found, LookUpHeader.ced will
  404.      load the appropriate compiler header file into CygnusEd and place the
  405.      cursor on the appropriate line.  As explained in the discussion of
  406.      LookUp.ced, LookUpHeader.ced will (if it can) use a view in CygnusEd
  407.      that was previously opened by LookUp.ced or LookUpHeader.ced.
  408.  
  409.  
  410.      2.5  LookUpTag.ced
  411.  
  412.      LookUpTag.ced is an ARexx program designed to work with CygnusEd
  413.      Professional and your own source code, be it in one or more modules. 
  414.      The word under your cursor (or immediately to the left of your cursor)
  415.      will be taken as the name of the function that you wish to look up in
  416.      your source files.  If your cursor is not on a word, a string
  417.      requester will appear, into which you can type the name of the
  418.      function you want to look up.  LookUpTag.ced will make use of the tags
  419.      file that you must have previously generated by using MakeTags or
  420.      GenTags (see below).  LookUpTag.ced assumes that this tags file may be
  421.      found in the same directory as the file in the current window of
  422.      CygnusEd.
  423.  
  424.      If the requested function is found in the tags file, LookUpTag.ced
  425.      will load the appropriate source module into CygnusEd if it is not
  426.      already loaded (or make use of an already-loaded copy) and place the
  427.      cursor on the appropriate line.
  428.  
  429.  
  430.      2.6  BlockSearch.ced
  431.  
  432.      This is a little freebie (an extra included at no charge in a free
  433.      package?!?) which allows you to highlight a block of text in CygnusEd
  434.      (don't cut it or copy it, though), and turn it into the object of a
  435.      search.  (The search will be a forward one, with the current settings
  436.      of case sensitivity, words only, and wildcards.)  If you want to
  437.      search backwards, you can 'Repeat Search Backwards' (AMIGA-a)
  438.      afterwards.  It sure beats retyping something into the search
  439.      requester.  You may install this ARexx program directly on a function
  440.      key.  Note that only the first word in the block will be taken, so if
  441.      you highlight the words "foo bar", and invoke BlockSearch.ced, the
  442.      object of the search will be "foo".
  443.  
  444.  
  445.      2.7  SetScriptBit.ced
  446.  
  447.      Another freebie (see above :->) which sets the script bit of the
  448.      current file in CygnusEd.  When I edit my script files and re-save
  449.      them, I lose the script bit.  If you install this ARexx program on a
  450.      CygnusEd function key, you can fix the script bit with a single
  451.      keystroke.
  452.  
  453.  
  454.      2.8  CommentBlock.ced
  455.  
  456.      An unfortunate feature of the C programming language is that comments
  457.      do not nest (although some compilers allow nested comments as an
  458.      option).  Sometimes, it is convenient to comment out a whole section
  459.      of code, but a problem arises if this section itself contains
  460.      comments.  CommentBlock.ced is an ARexx program that takes the
  461.      currently highlighted block in CygnusEd, encloses it in comments, and
  462.      replaces the comment brackets within the block ('/*' and '*/') with
  463.      false brackets that the compiler will ignore ('<*' and '*>').  Thus,
  464.      it becomes possible to comment a whole block of code, as if comments
  465.      did nest.  If you apply CommentBlock.ced to a block that already
  466.      contains some false brackets from a previous invocation, the false
  467.      brackets will grow (i.e. '<*' becomes '<<*', etc.) so that you may
  468.      successfully comment out something that already is.
  469.  
  470.  
  471.      2.9  UncommentBlock.ced
  472.  
  473.      UncommentBlock.ced is the matching inverse function to
  474.      CommentBlock.ced.  It takes the currently highlighted block in
  475.      CygnusEd, and begins by removing the first open comment sequence
  476.      ('/*') and the last close comment sequence ('*/').  (It is not a
  477.      problem if either an open or close comment is not found).  It then
  478.      replaces all the false comment brackets ('<*' and '*>') within the
  479.      block with true comment brackets ('/*' and '*/'), or it shrinks them
  480.      (i.e. '<<*' becoms '<*', etc.).  It effectively uncomments a block
  481.      that was commented out with CommentBlock.ced (described above).
  482.  
  483.  
  484.      2.10 ARexx Notes
  485.  
  486.      These ARexx programs are relatively robust examples of driving
  487.      CygnusEd and DOS commands from within an ARexx program.
  488.  
  489.      Of course, to run ARexx programs from within CygnusEd, you must run it
  490.      with the -keepio option, as in
  491.  
  492.           run ced -keepio
  493.  
  494.      One possible area of difficulty is in executing DOS commands from
  495.      within an ARexx program.  The ARexx command "ADDRESS COMMAND cmd"
  496.      executes the program specified by 'cmd'.  If you don't include the
  497.      full path to the file, then your path is searched.  As explained in
  498.      the ARexx 1.10 documentation, the path will be that in effect when
  499.      CygnusEd was run.  The DOS programs called by these ARexx programs
  500.      (DevKit programs GetAutoDoc and WBTF, and DOS commands delete and
  501.      search) must be in one of the directories in your path, or in the C:
  502.      directory.  This is also true of any program called by an "Auto:"
  503.      command without a full path specification, meaning cc, as, and ln. 
  504.      You may of course give a full path specification in your "Auto:"
  505.      commands, by doing something such as
  506.  
  507.           Auto: Aztec:ln ...
  508.  
  509.      However, take note that even if you give the full path to the
  510.      compiler, Aztec expects the assembler to be in the current directory
  511.      or anywhere in the path.
  512.  
  513.      The only way for an ARexx program to find which view in CygnusEd
  514.      Professional contains a particular file is to go to each successive
  515.      view until the correct one is found.  If you use CygnusEd's "Auto-
  516.      expand views" option (which makes the current view expand to the
  517.      largest possible size), then there will be a certain amount of
  518.      flashing as NextError.ced, LookUp.ced, and LookUpHeader.ced attempt to
  519.      locate the correct view.  If you can't do without "Auto-expand views",
  520.      you will have to put up with the flashing, at least until a few more
  521.      functions are added to the ARexx interface of CygnusEd Professional.
  522.  
  523.      An important point to note is that Aztec's cc compiler places its
  524.      error file AztecC.err in the current directory, which will be the
  525.      current directory at the time CygnusEd Professional was run.  If your
  526.      current directory is write-protected, cc won't be able to open the
  527.      error file.  CygnusEd has a menu option that lets you change its
  528.      current directory.  You may also add a line to Compile.ced such as
  529.           call pragma 'Directory', "RAM:"
  530.      which will change the current directory of the ARexx script to RAM:. 
  531.      Another straightforward solution is to use a file zapper on the Aztec
  532.      compiler cc and change the string 'AztecC.err' and to something like
  533.      'RAM:Az.err' (note that it has to be exactly the same length, i.e. 10
  534.      characters).  Use a text editor to make similar changes in Compile.ced
  535.      and NextError.ced, and Aztec's error messages will always go to the
  536.      RAM: disk.
  537.  
  538.  
  539.      2.11 CygnusEd Notes
  540.  
  541.      The ARexx programs in the DevKit make extensive use of the CygnusEd
  542.      ARexx interface.  Almost anything the user can make CygnusEd
  543.      Professional do can be done over the ARexx port.  For those interested
  544.      in adapting the DevKit to other text editors, here is a brief
  545.      description of the CygnusEd ARexx functions that are used in the ARexx
  546.      programs of the DevKit.  CygnusEd always returns the result of a
  547.      function in the variable named "result".
  548.  
  549.           address 'rexx_ced': Informs the ARexx server of the desire to
  550.                               communicate with CygnusEd.
  551.           cedtofront:    "cedtofront" brings the CygnusEd window to the
  552.                          front and activates it.
  553.           copy block:    "copy block" puts a copy of the currently
  554.                          highlighted block into the block buffer, and
  555.                          unhighlights it.  If the operation was successful,
  556.                          the return value "result" will be uninitialized
  557.                          (i.e. equal to the string "RESULT"), otherwise it
  558.                          will contain an error message (such as "No block
  559.                          marked").
  560.           cut block:     "cut block" behaves just like "copy block" except
  561.                          that the currently highlighted block is also
  562.                          removed from the file.
  563.           getstring:     "getstring" asks CygnusEd to put up a requester,
  564.                          into which you may type a string, which will be
  565.                          returned in the variable "result".
  566.           jumpto:        "jumpto line char" moves the cursor to the
  567.                          specified line and character (the first line of
  568.                          the file and the leftmost character are taken as
  569.                          1).
  570.           menu:          "menu menu item sub" executes the function at the
  571.                          specified menu, menu item, and sub item (count
  572.                          from zero up).  "menu 2 1 7" is used to set the
  573.                          tab size to eight.
  574.           next view:     CygnusEd supports multiple views (like having
  575.                          multiple windows, with the same or different file
  576.                          in each window).  "next view" moves the cursor
  577.                          into the next view.
  578.           okay1:         "okay1 text" causes CygnusEd to present a
  579.                          requester containing the specified text with a
  580.                          single gadget ("Resume?").
  581.           okay2:         "okay2 text" causes CygnusEd to present a
  582.                          requester containing the specified text with two
  583.                          gadgets ("Yes" and "No Way!").  A result of 1
  584.                          indicates that the "Yes" gadget was selected,
  585.                          while a result of 0 indicates that the "No Way!"
  586.                          gadget was chosen.
  587.           open:          "open file" causes CygnusEd to load the specified
  588.                          file into the current view.
  589.           open new:      "open new" causes CygnusEd to create a new (empty)
  590.                          view by splitting the current one.
  591.           search for:    "search for string" causes CygnusEd to initiate a
  592.                          forward search for the specified string.  If the
  593.                          search was successful, the return value "result"
  594.                          will be uninitialized (i.e. equal to the string
  595.                          "RESULT"), otherwise it will contain an error
  596.                          message (such as "'string' not found")
  597.           text:          "text string" will cause the supplied string to be
  598.                          entered at the current cursor position.
  599.  
  600.      CygnusEd also provides the "status n" command which, depending on the
  601.      value of n, returns a value or string known to the editor.  The
  602.      variable "result" contains the answer.  The ones used in the DevKit
  603.      are:
  604.  
  605.           8:   "status 8" returns the tab size.
  606.           18:  "status 18" returns the number of changes to the file in the
  607.                current view since the last time it was saved.
  608.           19:  "status 19" returns the full path and file name of the file
  609.                in the current view, eg. "Workbench:Sources/MyStuff.c"
  610.           20:  "status 20" returns the path of the file in the current
  611.                view, eg. "Workbench:Sources"
  612.           21:  "status 21" returns the name of the file in the current view
  613.                (without the path), eg. "MyStuff.c"
  614.           46:  "status 46" returns the x position of the cursor (the first
  615.                column is taken as 0).
  616.           47:  "status 47" returns the y position of the cursor (the first
  617.                line of the file is taken as 0).
  618.           55:  "status 55" returns a string which is the text on the
  619.                current line (tabs are not converted to spaces.)
  620.           60:  "status 60" returns a string which is the contents of the
  621.                block buffer.
  622.           66:  "status 66" returns the number of views currently open in
  623.                CygnusEd.
  624.  
  625.  
  626. 3.0  Shell/CLI Scripts and Other S Directory Stuff
  627.  
  628.      The DevKit includes a Shell script.
  629.  
  630.      3.1  SetSource
  631.  
  632.      SetSource is based on a script I use.  If I want to work on some c
  633.      files that are in a particular directory of my disk, say "cc:Tools", I
  634.      type at the Shell prompt:
  635.  
  636.           SetEnv Source cc:Tools
  637.  
  638.      As my ENV: directory is on my hard disk (and not in RAM:), this
  639.      environment variable survives reboots and power-offs.  When turn on
  640.      the computer to resume developing or when I reset the computer after a
  641.      crash, the script SetSource will get this environment variable and
  642.      assign the logical label src: to it.  I also invoke CygnusEd with a
  643.      file name (or more accurately a directory name) of src:, so that when
  644.      I want to open a file, the directory is set to my source directory.
  645.  
  646.      Scripts like SetSource that stuff parameters into commands look a bit
  647.      ugly, but can be very effective.
  648.  
  649.  
  650.      3.2  MakeTags
  651.  
  652.      MakeTags is a shell script that allows GenTags to be run for multiple
  653.      source files, with the result being stored in a file called tags in
  654.      the current directory.  Its syntax is
  655.  
  656.           MakeTags [pat]
  657.  
  658.      where pat is an optional pattern (defaulting to #?.c, or all .c
  659.      files).  So if you wanted to make tags for all .c files beginning with
  660.      a w, you would use
  661.  
  662.           MakeTags w#?.c
  663.  
  664.      MakeTags displays the name of each file as it is scanned.
  665.  
  666.      Normally you will use MakeTags, and not call GenTags directly.
  667.  
  668.  
  669.      3.3  RexxCommands
  670.  
  671.      RexxCommands is a file generated and used by CygnusEd Professional
  672.      (and placed in the S directory) which specifies the ARexx or DOS
  673.      commands that are attached to each function key.  RexxCommands makes
  674.      the following bindings for the ARexx scripts of the DevKit:
  675.  
  676.           F1   run rx Compile.ced
  677.           F2   NextError
  678.           F3   CommentBlock
  679.           F4   UncommentBlock
  680.           F6   SetScriptBit
  681.           F7   BlockSearch
  682.           F8   LookUpTags
  683.           F9   LookUpHeader
  684.           F10  LookUp
  685.  
  686.  
  687. 4.0  Executable Programs
  688.  
  689.      The DevKit contains five executable programs in the C directory that
  690.      are needed to run the ARexx scripts in the DevKit.
  691.  
  692.  
  693.      4.1  WBTF
  694.  
  695.      WBTF is the simplest one, and it just brings the Workbench screen to
  696.      the front, so that you may see what the compiler, or whatever is
  697.      doing.  It has no arguments.  (CygnusEd is brought to the front
  698.      through the ARexx command "cedtofront" that it provides.)
  699.  
  700.  
  701.      4.2  GetAutoDoc
  702.  
  703.      GetAutoDoc extracts the autodoc for a function.  You must have the
  704.      autodocs available in a directory, and have assigned the label
  705.      "AutoDocs:" to that directory.  Also, you must have run
  706.      MakeAutoDocIndex to build the indexes that GetAutoDoc needs to quickly
  707.      extract the autodoc for a function.
  708.  
  709.      To use GetAutoDoc, just type
  710.  
  711.           GetAutoDoc function
  712.  
  713.      Where function is the name of the Amiga system function you would like
  714.      the autodoc for (you may use upper, lower, or mixed case - it doesn't
  715.      matter).  If the function is found, the autodoc page will be sent to
  716.      the screen.  You may of course redirect the output to a file (that's
  717.      what LookUp.ced does.)  If the function is not found in the autodocs,
  718.      or some other error occurs, you will be told.
  719.  
  720.      If you just type
  721.  
  722.           GetAutoDoc
  723.  
  724.      You will get a brief summary of usage.
  725.  
  726.      GetAutoDoc returns an error code of 20 if a critical error occurred,
  727.      an error code of 5 if no autodoc for the desired function was found,
  728.      and an error code of 1 if the summary of usage was displayed.  The
  729.      error code of zero is reserved for successfully finding an autodoc. 
  730.      Furthermore, all error strings are guaranteed to begin with a dash
  731.      followed by a space, as in
  732.  
  733.           - Foo not found.
  734.  
  735.  
  736.      4.3  MakeAutoDocIndex
  737.  
  738.      MakeAutoDocIndex is a program that builds index files from the
  739.      autodocs so that GetAutoDoc may work efficiently.  It assumes that the
  740.      autodocs are the ones from the 1.3 Native Developer's Kit, available
  741.      from Commodore.  It scans all the files in the "AutoDocs:" directory
  742.      that end in ".doc".  These had better be genuine autodoc files.  A
  743.      genuine autodoc file contains:
  744.  
  745.           A list of the functions (or whatever, MakeAutoDocIndex doesn't
  746.           care)
  747.           Form Feed
  748.           A set of  {
  749.                     Autodocs for one function
  750.                     Form Feed
  751.                     }
  752.  
  753.      Assuming that nothing goes wrong, MakeAutoDocIndex will create a bunch
  754.      of files in a subdirectory called "Index" that it creates in the
  755.      "AutoDocs:" directory.  These files are called IndexA, IndexB, etc. 
  756.      Each file contains all the functions that start with that letter or
  757.      symbol (there will be an Index_ file).  The format will be:
  758.  
  759.           function; library; autodocfile offset
  760.  
  761.      where function is the name of the function (eg. OpenScreen), library
  762.      is the system library it belongs to (eg. intuition.library),
  763.      autodocfile is the full name of the autodoc file (eg.
  764.      AutoDocs:LibrariesA-K/intuition.doc) and offset is the byte offset
  765.      into the autodoc file where this function begins (eg. 68810).
  766.  
  767.      Some sharable libraries include an autodoc-type file.  You may easily
  768.      modify the source to MakeAutoDocIndex and recompile if you wish to
  769.      index these as well.  To modify MakeAutoDocIndex.c to inform it of
  770.      that new sub-directory, add it to the string array autodocdir and
  771.      increase DIRCOUNT by one.  If the supplied autodoc file isn't the
  772.      correct format, you may have to edit it a bit.  In particular, each
  773.      entry should be separated by a form feed, and there should be exactly
  774.      one form feed before the first entry.  Make sure that whatever is
  775.      ahead of the first entry has no form feeds.  The name of each function
  776.      should appear on the line after the form feed.  There may be no spaces
  777.      or tabs before the name (spaced or tabs after the name are ok).  The
  778.      name may be preceded by some other names (such as the library name)
  779.      with slashes between, for example
  780.  
  781.           intuition.library/OpenScreen
  782.  
  783.      is acceptable.
  784.  
  785.      MakeAutoDocIndex tries to catch and report any problems it might find. 
  786.      With the 1.3 autodocs there are no problems.
  787.  
  788.      MakeAutoDocIndex (like MakeHeaderIndex below) requires that the DOS
  789.      command 'sort' be in the C: directory or the current directory.
  790.  
  791.  
  792.      4.4  MakeHeaderIndex                                                  
  793.  
  794.      MakeHeaderIndex is a program that builds index files from the include
  795.      files, so that LookUpHeader.ced may work efficiently.  It assumes that
  796.      the includes are the ones from the 1.3 Native Developer's Kit,
  797.      available from Commodore.  You must assign the label "ch:" to the
  798.      directory containing your compiler headers.  MakeHeaderIndex scans the
  799.      eight subdirectories in "ch:" that it knows of - devices, exec,
  800.      graphics, hardware, intuition, libraries, resources, and workbench
  801.      (See MakeHeaderIndex.c).
  802.  
  803.      MakeHeaderIndex will create a bunch of files in a subdirectory called
  804.      "Index" that it creates in the "ch:" directory.  These files are
  805.      called IndexA, IndexB, etc.  Each file contains all the functions that
  806.      start with that letter.  The format will be:
  807.  
  808.           structure; headerfile; line
  809.  
  810.      or
  811.  
  812.           define; headerfile; line
  813.  
  814.      where structure or define is the name of the Amiga system structure
  815.      (eg. NewScreen) or #define'd value (eg. WBENCHSCREEN), headerfile is
  816.      the full name of the compiler header file (eg. ch:intuition/screens.h)
  817.      and line is the line number in the compiler header file where this
  818.      reference lies (eg. 95).
  819.  
  820.      MakeHeaderIndex will locate all #define'd constants that have a 
  821.  
  822.           #define
  823.  
  824.      at the very beginning of the line, as well as all structures that
  825.      begin with a
  826.  
  827.           struct
  828.  
  829.      at the very beginning of the line.  This seems to be true for the
  830.      Amiga compiler headers.
  831.  
  832.      If you have any headers that come with a sharable library, you must
  833.      place them in a sub-directory of the "ch:" directory.  You must modify
  834.      MakeHeaderIndex.c to inform it of that new sub-directory (add it to
  835.      the string array includedir and increase DIRCOUNT by one).  You must
  836.      also hope that all the #define's and struct's are at the extreme left
  837.      of their lines.
  838.  
  839.      MakeHeaderIndex tries to catch and report any problems it might find. 
  840.      With the 1.3 include files, there are no problems.
  841.  
  842.  
  843.      4.5  GenTags
  844.  
  845.      GenTags is a C-language program that will scan a C-language source
  846.      file and generate a tag entry for each function defined in that file. 
  847.      It takes as a single parameter the name of the source file:
  848.  
  849.           GenTags foo.c
  850.  
  851.      Each tag entry is of the following form:
  852.  
  853.           function; file; line
  854.  
  855.      where function is the name of the function that GenTags found, file is
  856.      the name of the file it was found in, and line is the line number
  857.      within that file where the function was defined.  The tags are sent to
  858.      the standard output, so you will probably want to redirect them
  859.      somewhere.  Usually, you will use the shell script MakeTags, which
  860.      calls GenTags for each file that matches a specified pattern, and
  861.      redirects the output to a file called tags.
  862.  
  863.      GenTags is smarter than for example the program that generates tag
  864.      files for the editor vi.  The only non-pathological case known for
  865.      which GenTags messes up is when there is an open comment ('/*') within
  866.      quotation marks.  Except for that case, it should successfully find
  867.      all the functions (it performed flawlessly on 500K of source files
  868.      that comprise one project).  Perhaps I left that one problem in so
  869.      that I have something to do for the next release...
  870.  
  871.      Since the tag file contains the line number where a certain function
  872.      was defined, if you modify a source module after you've generated the
  873.      tags for it, then LookUpTag.ced may miss by a bit if you've added or
  874.      removed lines ahead of the function in question.  As well, any
  875.      functions you've added to the source since you last generated the
  876.      tag files will of course not be in them.  You will periodically want
  877.      to remake the tag files, which fortunately is relatively quick and
  878.      painless (I can build tags for 500K of source in less than one minute,
  879.      but then I have access to a 68030 at work).
  880.  
  881.  
  882. 5.0  C Language Sources
  883.  
  884.      The sources for the five executable programs in the c directory of the
  885.      DevKit are provided.  They all compile under Aztec C, and contain
  886.      suitable "Auto:" commands to compile properly.  As such, they serve as
  887.      examples of how to set up "Auto:" commands properly.
  888.  
  889.  
  890. 6.0  Conclusion
  891.  
  892.      Thanks to Bill Hawes for technical assistance, and to Mike Sinz for
  893.      encouranging me to make CommentBlock and UncommentBlock nest properly.
  894.  
  895.      The ARexx and C language programs that comprise the DevKit make
  896.      developing on the Amiga much easier.  They also serve as good examples
  897.      of ARexx programming.  If you have any comments, suggestions, or
  898.      modifications, please bring them to my attention at
  899.  
  900.           Peter Cherna
  901.           5511 Westbourne Ave.,
  902.           Cote St. Luc, Quebec
  903.           Canada
  904.           H4V 2G9
  905.  
  906.  
  907. 7.0  Future Avenues
  908.  
  909.      Someday someone (perhaps me) will modify the DevKit so that
  910.      Compile.ced and NextError.ced work with the Lattice compiler.  As
  911.      Lattice's CodePRobe is ARexx compatible, LookUp and LookUpHeader
  912.      functions could be added to it, which would be useful.  Compile.ced
  913.      and NextError.ced could also be rewritten for other compilers (eg.
  914.      Modula 2.)
  915.  
  916.      One annoying problem I have with Aztec is that compiler warnings
  917.      aren't included in the AztecC.err file; they always go to the standard
  918.      output.  Aztec flags as warnings several things that I consider
  919.      errors, such as referencing foo->bar, where bar is not a field of the
  920.      structure foo, but is of some other structure.  I'd like to write a
  921.      program that would take the redirected output of Aztec's cc, and
  922.      format warning messages and stuff them into AztecC.err along with the
  923.      errors.
  924.  
  925.      As well, the ARexx programs might one day be rewritten to work with
  926.      other ARexx compatible editors.
  927.  
  928.      If anybody succeeds in any of these areas, I would be delighted to
  929.      hear about it.  As a suggestion, if you intend to rework Compile.ced
  930.      and NextError.ced to work with Lattice C, I would suggest you use some
  931.      other keyword than "Auto:", say "LAuto:", so that source code that
  932.      compiles under both Lattice and Aztec could have both "Auto:" and
  933.      "LAuto:" commands in it, and would compile depending on which version
  934.      of Compile.ced you used.
  935.