home *** CD-ROM | disk | FTP | other *** search
/ YPA: Your Privacy Assured / YPA.ISO / other_goodies / utilities / amigaguid.lha / AmigaGuide / AG_V34 / Docs / AmigaGuide.txt < prev   
Text File  |  1993-03-25  |  34KB  |  1,212 lines

  1.  
  2.                             AmigaGuide TM
  3.                            David N. Junod
  4.  
  5.    (C) Copyright 1990-93 Commodore-Amiga, Inc.  All Rights Reserved
  6.  
  7.  
  8.                             INTRODUCTION
  9.  
  10.  
  11. The standard Amiga keyboard sports a HELP key, yet there has been no
  12. system provided support for this key.  Now, there is AmigaGuide,
  13. which provides a standard method of displaying help and other on-line
  14. documentation to the user.
  15.  
  16.  
  17.  
  18. Capabilities
  19.  
  20. AmigaGuide uses an Intuition window that contains a scroll bar,
  21. buttons and pull-down menus, to display plain ASCII text files or
  22. AmigaGuide databases.
  23.  
  24. An AmigaGuide database is a set of related documents contained in one
  25. file.  Each document may contain references to other documents, using
  26. what is called a link.  A document may contain any number of links,
  27. pointing to any number of other documents.  When the user selects a
  28. link, the document that the link points to will be displayed.  The
  29. user may then use the links to read through the database, following
  30. whatever path they may choose.  The technical term for AmigaGuide's
  31. abilities, is hypertext.
  32.  
  33. The user may at any time print a document or a portion of the
  34. document.  They may also send portions of a document to the
  35. clipboard, for use in other applications.
  36.  
  37. Using ARexx, the user may write scripts, or an application could
  38. provide scripts, to control AmigaGuide.
  39.  
  40. Cross-reference tables can be loaded that specify where a keyword, or
  41. phrase is defined.  The user can then use AmigaGuide's Find Document
  42. facility to quickly display a document based on keyword, without
  43. having to know the name of the database that it is located in.
  44.  
  45. AmigaGuide provides a unique feature to hypertext systems, called
  46. Dynamic Nodes.  A Dynamic Node is a hypertext or plain text document
  47. that is generated in real-time as opposed to coming from a static
  48. file.  An application that generates Dynamic Nodes is called a
  49. Dynamic Node Host.
  50.  
  51.  
  52.  
  53. Interfacing
  54.  
  55. AmigaGuide databases are accessed in three different ways:
  56.  
  57.  
  58.   o  Databases can be browsed directly from the Workbench or Shell
  59.      using a utility named AmigaGuide, a hypertext replacement for
  60.      More.
  61.  
  62.   o  AmigaGuide support can be added to an existing application, that
  63.      supports ARexx, by using AmigaGuide's ARexx function host
  64.      capabilities.
  65.  
  66.   o  Applications can use the functions of AmigaGuide to provide help
  67.      on gadgets, menus and windows.  For example, the user could
  68.      position the pointer over any gadget or menu item, press help,
  69.      and the appropriate document would be displayed in the
  70.      AmigaGuide window.  The application could also have AmigaGuide
  71.      display a pertinent portion of the current project.
  72.  
  73.  
  74.  
  75. Other Uses
  76.  
  77. In addition to help or on-line documentation, AmigaGuide has other
  78. possible uses.  For example,
  79.  
  80.  
  81.   Tutorials
  82.   An application that has an ARexx port and supports AmigaGuide could
  83.   set up a help system that not only provides help, but could also give
  84.   examples. The user could read about a feature, then click on the
  85.   EXAMPLE button, which would run an ARexx script that would give an
  86.   example of use.  For instances, to show Pattern Fill, the script
  87.   could draw a circle, select a pattern, and then fill the circle.
  88.  
  89.  
  90.   Computer Aided Instruction
  91.   The student could read about different topics, following links.  A
  92.   multiple choice quiz could be set up at the end where the questions
  93.   and answers run ARexx scripts to accumulate the score.
  94.  
  95.  
  96.   Program by Query
  97.   Many programmers develop using a Cut & Paste technique.  They
  98.   clip modules from the various applications or utilities that they
  99.   have written, and paste them together to build new applications.
  100.   A database could be set up of all these different code fragments
  101.   (such as loading and saving ILBM's, clipboard access, playing sounds,
  102.   etc.), you could step through, answering questions, while the sections
  103.   that you need are being appended to a new source file.
  104.  
  105.  
  106.  
  107.                USING AmigaGuide FROM WORKBENCH OR CLI
  108.  
  109.  
  110. A number of utilities are provided to access AmigaGuide databases
  111. from the Workbench or Shell.  These utilities are:
  112.  
  113.  
  114.   AmigaGuide
  115.   This tool is much like the system utility, More, but is also capable of
  116.   interpreting AmigaGuide databases.
  117.  
  118.   LoadXRef
  119.   Used to load a cross-reference from disk into memory.  Multiple
  120.   files can be loaded.
  121.  
  122.   ExpungeXRef
  123.   Used to clear the cross-reference table from memory.
  124.  
  125.  
  126. AmigaGuide
  127.  
  128. The AmigaGuide utility is used for browsing through AmigaGuide
  129. databases. It can be run from the Workbench or the Shell.
  130.  
  131. To use it from Workbench, set the default tool of an AmigaGuide
  132. database's icon to AmigaGuide.  Currently, the AmigaGuide utility
  133. doesn't recognize any tool type parameters.
  134.  
  135. From the Shell, AmigaGuide uses the following command template.
  136.  
  137.  
  138.   DataBase,Document/K,Line/N,PubScreen/K,PortName/K:
  139.  
  140.  
  141. The following are descriptions of the arguments.
  142.  
  143.  
  144.   DataBase
  145.   The name of the AmigaGuide database to display.
  146.  
  147.   AmigaGuide will look in the current directory for the database.  If the
  148.   database isn't found, then AmigaGuide will search through its path for
  149.   the database.  To set the path, see the Path paragraph in the USER
  150.   PREFERENCES section.
  151.  
  152.   Document
  153.   The document within the database to display.  AmigaGuide will use
  154.   the cross-reference table to automatically supply the DataBase and
  155.   Line parameters.
  156.  
  157.   Line
  158.   The line of the document to start displaying from.
  159.  
  160.   PubScreen
  161.   The public screen to open on.  Remember that public screen names are
  162.   case sensitive.
  163.  
  164.   PortName
  165.   The name to assign to the ARexx port for this occurence of AmigaGuide.
  166.  
  167.  
  168. LoadXRef
  169.  
  170. The LoadXRef utility can be used from Workbench or the Shell to load
  171. cross-reference files from disk into memory.  Multiple cross-
  172. reference files may be loaded at a time.
  173.  
  174. From Workbench, just set the default tool of a cross-reference file's
  175. project icon to LoadXRef.  This tool doesn't support any tool type
  176. parameters.
  177.  
  178. From the Shell, just specify the name of the cross-reference file to
  179. load.  LoadXRef will look in the current directory for the file.  If
  180. the file isn't found, then LoadXRef will search through the users
  181. preference path for the file.
  182.  
  183.  
  184. ExpungeXRef
  185.  
  186. The ExpungeXRef utility is used to remove all entries from the cross-
  187. reference table in memory.
  188.  
  189.  
  190.  
  191.                           USER PREFERENCES
  192.  
  193.  
  194. AmigaGuide allows a number of items to be tailored to the users'
  195. preference.  These preference items are stored in environment variables.
  196. The AmigaDOS command SetEnv can be used to set any of these variables.
  197.  
  198. In order to set any of the following environment variables, an
  199. ENV:AmigaGuide directory must be made.
  200.  
  201.   makedir ENV:AmigaGuide
  202.  
  203. A Preference Editor that sets the AmigaGuide preferences would write
  204. in the ENV:AmigaGuide directory when "Use is selected, and write in
  205. the ENVARC:AmigaGuide directory when "Save" is selected.
  206.  
  207. Following is a list of the variable names, and what they control.
  208.  
  209.  
  210. Path
  211.  
  212. This variable contains the list of directory names that AmigaGuide will
  213. search through when it attempts to open a database.  The directory names
  214. are separated by a space.
  215.  
  216.   For example:
  217.  
  218.     SetEnv AmigaGuide/Path "Workbench:Autodocs Workbench:Includes"
  219.  
  220.  
  221. Text
  222.  
  223. Used to specify the graphical style that the links are presented in.
  224. The possible styles are:
  225.  
  226.     BUTTON    Draw a raised border around the text (default).
  227.     UNDERLINE    Underline the text.
  228.     BOLD    Bold the text.
  229.     ITALIC    Italicize the text.
  230.  
  231.   For example:
  232.  
  233.     SetEnv AmigaGuide/Text BUTTON
  234.  
  235.  
  236. Pens
  237.  
  238. This variable provides the user with the ability to specify the
  239. colors to use for the various renderings that AmigaGuide performs.
  240.  
  241.     SetEnv AmigaGuide/Pens <abcdefgh>
  242.  
  243.   Where:
  244.  
  245.     a = Background pen
  246.     b = Button text pen
  247.     c = Button background pen
  248.     d = Highlighted button text pen
  249.     e = Highlighted button background pen
  250.     f = Outline pen
  251.     g = Highlight outline pen
  252.     h = Text on background pen
  253.  
  254.   For example:
  255.  
  256.     SetEnv AmigaGuide/Pens 21213001
  257.     SetEnv AmigaGuide/Text BOLD
  258.  
  259.  
  260. Internally, AmigaGuide subtracts '0' from the pen number, so values
  261. can range from 0 to 207.
  262.  
  263.  
  264.                    AUTHORING AmigaGuide DOCUMENTS
  265.  
  266.  
  267. Authoring an AmigaGuide database, or any hypertext database for that
  268. matter, is a difficult task.  It takes a lot of insight into the
  269. subject matter and how the pieces relate to each other.  A database
  270. must consist of documents that relate to each, documents must be
  271. broken up into manageable chunks, and links must be carefully thought
  272. out.  A document should consist of information dealing with one
  273. topic. Each document should contain links to other related documents.
  274.  
  275. An AmigaGuide database is ASCII text with embedded commands that tell
  276. AmigaGuide how to interpret the database.  A database should consist
  277. of a main table of contents and a number of related documents.
  278.  
  279.  
  280. Label Commands
  281.  
  282. These are commands that can be used within a database.  Commands must
  283. start in the very first column of a line.  If a line begins with an @
  284. sign, then it is interpreted as a command.
  285.  
  286.  
  287.   @DATABASE <name>
  288.   Must be the very first line of a Amiga HyperText document.
  289.  
  290.   @MASTER <path>
  291.   Complete path of the source document used to define this HyperText
  292.   database.
  293.  
  294.   @NODE <name> <title>
  295.   Indicate the start of a node (page/article/section). The first node,
  296.   or main node, must be named MAIN.  MAIN must be the master table of
  297.   contents for the database.
  298.  
  299.   @DNODE <name>
  300.   Indicates the start of a dynamic node.  The HyperText system uses the
  301.   callback hooks to obtain the document from a document provider.
  302.  
  303.   @INDEX <name/node>
  304.   Specify the name of the index node, accessed by the Index button.  Can
  305.   be a node in an external database.
  306.  
  307.   @REMARK <remark>
  308.   Remark (not displayed to the user).
  309.  
  310.  
  311. Node Label Commands
  312.  
  313. These are commands that can be used within a @NODE.
  314.  
  315.  
  316.   @ENDNODE <name>
  317.   Indicate the end of a node.  Must start at the beginning of a line.
  318.  
  319.   @TITLE <title>
  320.   Title to display in the title bar of the window during the display of
  321.   this node.  Must start at the beginning of a line.
  322.  
  323.   @TOC <node name>
  324.   Name of the node that contains the table of contents for this node.
  325.   Defaults to MAIN.  This is the node that is displayed when the user
  326.   presses the "Contents" button.
  327.  
  328.   @PREV <node name>
  329.   Node to display when the user selects "< Browse"
  330.  
  331.   @NEXT <node name>
  332.   Node to display when the user selects "Browse >"
  333.  
  334.   @{<label> <command>}
  335.   Indicate a textual link point.  Can be anywhere in a line.
  336.  
  337.  
  338. Action Commands
  339.  
  340. These are commands that can be assigned to a link point.
  341.  
  342.  
  343.   ALINK <name> <line>
  344.   Load the named node into a new window, with <line> at the top of the
  345.   display.
  346.  
  347.   CLOSE
  348.   Close the window (should only be used on windows that where started
  349.   with alink).
  350.  
  351.   LINK <name> <line>
  352.   Load the named node, with <line> at the top of the display.
  353.  
  354.   RX <command>
  355.   Execute an ARexx macro.
  356.  
  357.   RXS <command>
  358.   Execute an ARexx string file.  To display a picture, use 'ADDRESS
  359.   COMMAND DISPLAY <picture name>', to display a text file 'ADDRESS
  360.   COMMAND MORE <doc>'.
  361.  
  362.   SYSTEM <command>
  363.   Execute an AmigaDOS command.
  364.  
  365.   QUIT
  366.   Shutdown the current database.
  367.  
  368.  
  369. Example AmigaGuide Database
  370.  
  371. The following is an example of an AmigaGuide database.  It doesn't
  372. contain any 'useful' information, but it does show the usage of some
  373. of the commands.
  374.  
  375.  
  376.     @database "example.guide"
  377.     @master "example.doc"
  378.  
  379.     @node Main "Example AmigaGuide database"
  380.  
  381.     Table of Contents
  382.  
  383.        @{"ARexx" link ARexx}
  384.        @{"Shell" link Shell}
  385.        @{"Workbench" link Workbench}
  386.  
  387.     @endnode
  388.  
  389.     @node ARexx
  390.     Put something here about ARexx
  391.     @endnode
  392.  
  393.     @node Shell
  394.     Put something here about the Shell
  395.     @endnode
  396.  
  397.     @node Workbench
  398.     Put something here about Workbench. Say that it has @{"icons" link icon}.
  399.     @endnode
  400.  
  401.     @icon "Workbench Icons"
  402.     Those little pictures that you can drag around.
  403.     @endnode
  404.  
  405.  
  406.  
  407.                             AREXX SCRIPTS
  408.  
  409.  
  410. It is possible to control AmigaGuide using ARexx.  Each occurrence of
  411. AmigaGuide has an ARexx port.  The AmigaGuide shared system library
  412. is also an ARexx function host.
  413.  
  414.  
  415. Port Naming
  416.  
  417. The default port name is AMIGAGUIDE.# where # is the occurrence. With
  418. the AmigaGuide utility, a port name can be specified as a command
  419. line argument.  An application with an AmigaGuide interface can also
  420. provide the port name.
  421.  
  422.  
  423. ARexx Commands
  424.  
  425. Any of the following action commands are also ARexx commands.  All
  426. commands are not case-sensitive.
  427.  
  428.  
  429.   ALINK <name> <line>
  430.   Load the named node into a new window, with <line> at the top of the
  431.   display.
  432.  
  433.   CLOSE
  434.   Close the window (should only be used on windows that where started
  435.   with alink).
  436.  
  437.   LINK <name> <line>
  438.   Load the named node, with <line> at the top of the display.
  439.  
  440.   SYSTEM <command>
  441.   Execute an AmigaDOS command.
  442.  
  443.   QUIT
  444.   Shutdown the current database.
  445.  
  446.  
  447. ARexx Functions
  448.  
  449. The amigaguide.library is an ARexx function library.  The library can
  450. be added as a function host with the following lines:
  451.  
  452.  
  453.   /* Load the HyperText library as a function host */
  454.   IF ~SHOW('L','amigaguide.library') THEN
  455.      CALL ADDLIB('amigaguide.library',0,-30)
  456.  
  457.  
  458. It supports the following functions (function names are not case-
  459. sensitive).
  460.  
  461.  
  462.   ShowNode
  463.   PUBSCREEN/K,DATABASE/K,NODE/K,LINE/N
  464.   Display a node on the named screen.  Defaults to the Main node, on
  465.   the Workbench screen.  If DATABASE isn't specified, then will search
  466.   through the cross-reference list to get the database name.
  467.  
  468.  
  469.   LoadXRef
  470.   NAME/K
  471.   Load a cross-reference file into memory.
  472.  
  473.  
  474.   GetXRef
  475.   NODE/K
  476.   Return information on NODE.  Format of the text string returned is
  477.   "NODE" "DATABASE" TYPE LINE.
  478.  
  479.   ExpungeXRef
  480.   ,
  481.   Flush the cross-reference list from memory.
  482.  
  483.  
  484.  
  485.          ADDING AN AmigaGuide INTERFACE TO YOUR APPLICATION
  486.  
  487.  
  488. Applications can add AmigaGuide support, using the functions within
  489. the amigaguide.library.
  490.  
  491. The HyperApp example on disk illustrates how to add context sensitive
  492. help to an application.
  493.  
  494.  
  495.  
  496.                         CROSS REFERENCE FILES
  497.  
  498.  
  499. AmigaGuide allows cross-reference tables to be loaded that specify
  500. what document a keyword is defined in.  This cross-reference table is
  501. used by the "Find Document" requester to locate a node.  It is also
  502. used by the AD2HT utility to construct hypertext versions of the
  503. system Autodoc files.
  504.  
  505. A cross-reference file follows a layout similar to the devs:mountlist
  506. format. The table itself starts with a line that consists of the
  507. keyword XREF: and ends with a line that contains a # as the only
  508. uncommented character. Comments can be included in the C-style
  509. format, beginning with "/*" and ending with "*/".
  510.  
  511.  
  512.     /* This is a comment */
  513.     XREF:
  514.     ...
  515.     "Gadget"    "intuition/intuition.h"    215 3
  516.     ...
  517.     #
  518.  
  519.  
  520. A cross-reference entry consists of four words:
  521.  
  522.  
  523.   Keyword
  524.   The keyword that is being defined.
  525.  
  526.   File
  527.   The ASCII file or database that the keyword is defined in.
  528.  
  529.   Line
  530.   The line within the node that the keyword is defined on.
  531.  
  532.   Type
  533.   This field indicates the type of keyword.  Possible values are.
  534.  
  535.     0  Generic AmigaGuide link.
  536.     1  Describes a function.
  537.     2  Describes a command.
  538.     3  Points to an include file.
  539.     4  Describes a macro.
  540.     5  Describes a structure.
  541.     6  Describes a structure field.
  542.     7  Describes a type definition.
  543.     8  Describes a define.
  544.  
  545.  
  546. Loading a Cross Reference List
  547.  
  548. A cross-reference list can be loaded from disk using the LoadXRef()
  549. function.  The format is.
  550.  
  551.  
  552.   success = LoadXRef(lock, name);
  553.  
  554.   LONG success;
  555.   BPTR lock;
  556.   STRPTR name;
  557.  
  558.  
  559. The arguments are.
  560.  
  561.  
  562.   lock
  563.   Lock on the directory where the file is located.  May be NULL.
  564.  
  565.   name
  566.   Name of the cross-reference file to load.  LoadXRef will search the
  567.   user preference path.
  568.  
  569.  
  570. Returns
  571.  
  572.  
  573.   -1  Indicates that the load was aborted by a control-C.
  574.  
  575.    0  Unable to load the file.
  576.  
  577.    1  Successfully loaded the file.
  578.  
  579.    2  No changes have been made since the last time that this file was
  580.       loaded.
  581.  
  582.  
  583. Access to the Cross Reference List
  584.  
  585. An application can use the GetAmigaGuideAttr() function to obtain a
  586. pointer to the cross-reference list.  The application then may search
  587. through the list, or even save the list to disk.  Note that access to
  588. this list is read-only, and must be enclosed between a call to
  589. LockAmigaGuideBase() and UnlockAmigaGuideBase().
  590.  
  591.  
  592.     struct List *list;
  593.     LONG key;
  594.  
  595.     /* Lock the AmigaGuideBase for exclusive access */
  596.     key = LockAmigaGuideBase(NULL);
  597.  
  598.     /* Get a pointer to the cross-reference list */
  599.     if (GetAmigaGuideAttr(AGA_XRefList, NULL, &list))
  600.     {
  601.     /* Do something with the list */
  602.     }
  603.  
  604.     /* Unlock AmigaGuideBase */
  605.     UnlockAmigaGuideBase(key);
  606.  
  607.  
  608.  
  609. The cross-reference list consist of nodes of struct XRef, defined in
  610. <libraries/amigaguide.h>.
  611.  
  612.  
  613.     /* Cross-reference node */
  614.     struct XRef
  615.     {
  616.         struct Node xr_Node;    /* Embedded node */
  617.         UWORD xr_Pad;        /* Padding */
  618.         struct DocFile *xr_DF;    /* (Private) Document defined in */
  619.         STRPTR xr_File;        /* Name of document file */
  620.         STRPTR xr_Name;        /* Name of item */
  621.         LONG xr_Line;        /* Line defined at */
  622.     };
  623.  
  624.     #define    XRSIZE    (sizeof (struct XRef))
  625.  
  626.  
  627. Following are the field definitions.
  628.  
  629.  
  630.   xr_Node
  631.   Embedded node structure.
  632.   xr_Node.ln_Name points to xr_Name.
  633.   xr_Node.ln_Type contains the type of the keyword.
  634.  
  635.   xr_Pad
  636.   Used to align the remaining fields.
  637.  
  638.   xr_DF
  639.   Private pointer.
  640.  
  641.   xr_File
  642.   Pointer to the name of the file that xr_Name is defined in.
  643.  
  644.   xr_Name
  645.   Pointer to the keyword.
  646.  
  647.   xr_Line
  648.   The line, within xr_File, that xr_Name is defined on.
  649.  
  650.  
  651.  
  652.                           DYNAMIC NODE HOST
  653.  
  654.  
  655. AmigaGuide provides a unique feature to hypertext systems, called
  656. Dynamic Nodes.  A Dynamic Node is a hypertext or plain text document
  657. that is generated in real-time as opposed to coming from a static
  658. file.  An application that generates Dynamic Nodes is called a
  659. Dynamic Node Host.
  660.  
  661. If a link point within a document isn't resolved, it will query a
  662. list of Dynamic Node Hosts to see if any one of these external
  663. applications can resolve the node.
  664.  
  665. This feature allows for dynamic interaction with constantly changing
  666. data.  This feature is useful for AmigaGuide authoring tools,
  667. interactive development environments, extremely context sensitive
  668. help systems, to name a few.
  669.  
  670. Dynamic Nodes has been implemented using an Object Oriented
  671. Programming paradigm.  When a link point hasn't been resolved a
  672. HM_FindNode message is sent to each Dynamic Node Host on the list.
  673. Once the node has been found, then a HM_OpenNode is sent to the
  674. Dynamic Node Host that the node belongs to.  HM_CloseNode is sent to
  675. the host once the node has been exited.
  676.  
  677.  
  678. Initializing a Dynamic Node Host
  679.  
  680. In order for an application to register itself as a Dynamic Node
  681. Host, it must initialize a hook and add the hook to the AmigaGuide
  682. Dynamic Node list, using the AddAmigaGuideHost() library call.
  683.  
  684. The hook structure as defined in <utility/hooks.h>.
  685.  
  686.  
  687.     /* Standard hook structure */
  688.     struct Hook
  689.     {
  690.         struct MinNode h_MinNode;
  691.         ULONG (*h_Entry)();        /* assembler entry point */
  692.         ULONG (*h_SubEntry)();        /* often HLL entry point */
  693.         VOID *h_Data;            /* owner specific */
  694.     };
  695.  
  696.  
  697. The AddAmigaGuideHost() function returns a pointer to an
  698. AmigaGuideHost structure.  This structure, defined in
  699. <libraries/amigaguide.h>, is as follows.
  700.  
  701.  
  702.     /* Callback handle */
  703.     struct AmigaGuideHost
  704.     {
  705.         struct Hook agh_Dispatcher;    /* Dispatcher */
  706.         ULONG agh_Reserved;        /* Must be 0 */
  707.         ULONG agh_Flags;
  708.         ULONG agh_UseCnt;        /* Number of open nodes */
  709.         APTR agh_SystemData;        /* Reserved for system use */
  710.         APTR agh_UserData;        /* Anything you want... */
  711.     };
  712.  
  713.  
  714. Following are the field definitions for the AmigaGuideHost structure.
  715.  
  716.  
  717.   agh_Dispatcher
  718.   This is a copy of the Hook that was passed to AddAmigaGuideHost().
  719.  
  720.   agh_UserData
  721.   Can be manipulated by the Dynamic Node Host any way it sees fit.
  722.  
  723.  
  724.   The other fields are not to be manipulated in any way.
  725.  
  726.  
  727. Removing a Dynamic Node Host
  728.  
  729. A Dynamic Node Host is removed using the RemoveAmigaGuideHost()
  730. library function.  The application must successfully remove the hook
  731. before exiting, otherwise AmigaGuide would end up calling the hook
  732. function, that has been unloaded from the system, causing a system
  733. crash.
  734.  
  735. The following code fragment illustrates how to initialize and remove
  736. a Dynamic Node Host.
  737.  
  738.  
  739.     #include <exec/types.h>
  740.     #include <libraries/amigaguide.h>
  741.     #include <clib/exec_protos.h>
  742.     #include <clib/amigaguide_protos.h>
  743.     #include <pragmas/exec_pragmas.h>
  744.     #include <pragmas/amigaguide_pragmas.h>
  745.     #include <stdio.h>
  746.  
  747.     extern struct Library *SysBase, *DOSBase;
  748.     struct Library *AmigaGuideBase;
  749.  
  750.     #define    ASM    __asm
  751.     #define    REG(x)    register __ ## x
  752.  
  753.     ULONG __saveds dispatchDNH(struct Hook *, STRPTR, Msg);
  754.     ULONG ASM hookEntry(REG(a0) struct Hook *,REG(a2) VOID *,REG(a1) VOID *);
  755.  
  756.     /* Callback hook dispatcher */
  757.     ULONG __asm hookEntry (
  758.         REG(a0) struct Hook *h,
  759.         REG(a2) VOID *obj,
  760.         REG(a1) VOID *msg)
  761.     {
  762.         /* Pass the parameters on the stack */
  763.         return ((h->h_SubEntry)(h, obj, msg));
  764.     }
  765.  
  766.     main (int argc, char **argv)
  767.     {
  768.     struct Hook hook;
  769.     AMIGAGUIDEHOST hh;
  770.  
  771.     /* amigaguide.library works with 1.3 and newer versions of the OS */
  772.     if (AmigaGuideBase = OpenLibrary ("amigaguide.library", 33))
  773.     {
  774.         /* Initialize the hook */
  775.         hook.h_Entry = hookEntry;
  776.         hook.h_SubEntry = dispatchDNH;
  777.  
  778.         /* Add the AmigaGuideHost to the system */
  779.         if (hh = AddAmigaGuideHost (&hook, "ExampleHost", NULL))
  780.         {
  781.         printf ("Added AmigaGuideHost 0x%lx\n", hh);
  782.  
  783.         /* Wait until we're told to quit */
  784.         Wait (SIGBREAKF_CTRL_C);
  785.  
  786.         printf ("Remove AmigaGuideHost 0x%lx", hh);
  787.  
  788.         /* Try removing the host */
  789.         while (RemoveAmigaGuideHost (hh, NULL) > 0)
  790.         {
  791.             /* Wait a while */
  792.             printf (".");
  793.             Delay (250);
  794.         }
  795.         printf ("\n");
  796.         }
  797.         else
  798.         {
  799.         printf ("Couldn't add AmigaGuideHost\n");
  800.         }
  801.  
  802.         /* close the library */
  803.         CloseLibrary (AmigaGuideBase);
  804.     }
  805.     }
  806.  
  807.  
  808. Handling Dynamic Node Host Messages
  809.  
  810. Once the Dynamic Node Host has been added to AmigaGuide, it can start
  811. receiving messages for different requests.
  812.  
  813. Currently, AmigaGuide supports the following methods, or message
  814. types, for a Dynamic Node Host.
  815.  
  816.  
  817.   HM_FindNode
  818.   When AmigaGuide can't resolve a link, then it sends a HM_FindNode
  819.   message to all Dynamic Node Hosts to see which host defines the
  820.   node.
  821.  
  822.   HM_OpenNode
  823.   Once AmigaGuide locates the host that defines a node, using the
  824.   HM_FindNode message, then the HM_OpenNode message is sent to that
  825.   host to ask it to open the node.
  826.  
  827.   HM_CloseNode
  828.   Once the user has closed all occurrences of a Dynamic Node, then
  829.   AmigaGuide sends the HM_CloseNode message to the host that opened
  830.   the node.
  831.  
  832.   HM_Expunge
  833.   AmigaGuide sends this message to all Dynamic Node Hosts when the
  834.   Expunge vector of amigaguide.library is invoked, or the
  835.   ExpungeDataBases() function is called.
  836.  
  837.  
  838. Several of the methods receive a TagItem array as an argument.
  839. Currently the following tags are supported.  The tag values are
  840. defined in <libraries/amigaguide.h>.
  841.  
  842.  
  843.   HTNA_Screen
  844.   A pointer to the screen on which source AmigaGuide window resides.
  845.  
  846.   HTNA_Pens
  847.   The pen array associated with the screen.
  848.  
  849.   HTNA_Rectangle
  850.   A Rectangle structure (defined in <graphics/gfx.h>) containing the
  851.   dimensions of the window.
  852.  
  853.  
  854. Each method requires one or more parameters.  The MethodID is the
  855. only common parameter for each method.
  856.  
  857.  
  858. HM_FindNode
  859.  
  860. Used to locate the Dynamic Node Host that a node is defined by.  When
  861. a Dynamic Node Host receives a HM_FindNode message for a node that it
  862. owns, it should reply with TRUE, otherwise it must respond with FALSE.
  863.  
  864. The HM_FindNode method receives the following arguments:
  865.  
  866.  
  867.     /* HM_FindNode */
  868.     struct opFindHost
  869.     {
  870.         ULONG MethodID;
  871.         struct TagItem *ofh_Attrs;    /*  R: Additional attributes */
  872.         STRPTR ofh_Node;        /*  R: Name of node */
  873.         STRPTR ofh_TOC;            /*  W: Table of Contents */
  874.         STRPTR ofh_Title;        /*  W: Title to give to the node */
  875.         STRPTR ofh_Next;        /*  W: Next node to browse to */
  876.         STRPTR ofh_Prev;        /*  W: Previous node to browse to */
  877.     };
  878.  
  879.  
  880. The field definitions are as follows
  881.  
  882.  
  883.   ofh_Attrs
  884.   This field contains a pointer to a TagItem array of attributes for
  885.   the message.  This field is read-only.
  886.  
  887.   ofh_Node
  888.   The name of the node to open.  This field is read-only.  It is
  889.   possible for this name to contain parameters that need to be
  890.   parsed.  For example, the command that triggered the link could
  891.   have been:
  892.  
  893.     Link "snd/beep 320"
  894.  
  895.   In which case, the ofh_Node field would contain:
  896.  
  897.     beep 320
  898.  
  899.   ofh_TOC
  900.   The Table of Contents to assign to this node.  This is the name of
  901.   the node to link to, if the "Contents" button is pressed.  This
  902.   field can be written to (not implemented).
  903.  
  904.   ofh_Title
  905.   The title to assigned to this node.  This field can be written to.
  906.  
  907.   ofh_Next
  908.   The name of the logical next node.  This is the name of the node to
  909.   link to if the "Browse >" button is pressed. This field can be
  910.   written to.
  911.  
  912.   ofh_Prev
  913.   The name of the logical previous node.  This is the name of the
  914.   node to link to if the "< Browse" button is pressed.   This field
  915.   can be written to.
  916.  
  917.  
  918.  
  919. HM_OpenNode
  920.  
  921. Once AmigaGuide locates the host that defines a node, using the
  922. HM_FindNode message, then the HM_OpenNode message is sent to that
  923. host to ask it to open the node. If the Dynamic Node Host is able to
  924. open the node, then it should respond with TRUE, otherwise respond
  925. with FALSE.
  926.  
  927. The HM_OpenNode method receives the following arguments:
  928.  
  929.  
  930.     /* HM_OpenNode, HM_CloseNode */
  931.     struct opNodeIO
  932.     {
  933.         ULONG MethodID;
  934.         struct TagItem *onm_Attrs;    /*  R: Additional attributes */
  935.         STRPTR onm_Node;        /*  R: Node name and arguments */
  936.         STRPTR onm_FileName;        /*  W: File name buffer */
  937.         STRPTR onm_DocBuffer;        /*  W: Node buffer */
  938.         ULONG onm_BuffLen;        /*  W: Size of buffer */
  939.         ULONG onm_Flags;        /* RW: Control flags */
  940.     };
  941.  
  942.  
  943. The field definitions are as follows
  944.  
  945.  
  946.   onm_Attrs
  947.   This field contains a pointer to a TagItem array of attributes for the
  948.   message.  This field is read-only.
  949.  
  950.   onm_Node
  951.   The name of the node to open.  This field is read-only.  It is possible
  952.   for this name to contain parameters that need to be parsed.  For
  953.   example, the command that triggered the link could have been:
  954.  
  955.     Link "snd/beep 320"
  956.  
  957.   In which case, the onm_Node field would contain:
  958.  
  959.     beep 320
  960.  
  961.   onm_FileName
  962.   If you want AmigaGuide to read a particular node from disk, then supply
  963.   the file name here.  The file can either be a straight ASCII file or an
  964.   AmigaGuide document (not a database).  The application can write to
  965.   this field.
  966.  
  967.   onm_DocBuffer
  968.   If you are dynamically creating a node in memory, then use this field
  969.   to point to the buffer.  If this field is used, then the onm_BuffLen
  970.   field must be filled in also.  The application is in charge of freeing
  971.   onm_DocBuffer when it is done (indicated by a HM_CloseNode message).
  972.   The application can write to this field.
  973.  
  974.   onm_BuffLen
  975.   The length of the buffer that onm_DocBuffer points to.  The
  976.   application can write to this field.
  977.  
  978.   onm_Flags
  979.   These are control flags that the Dynamic Node Host can set.
  980.  
  981.     HTNF_KEEP - Don't flush this node from memory until the database is
  982.     closed.  This will delay the HM_CloseNode message until the database
  983.     is closed.
  984.  
  985.     HTNF_ASCII - The node is straight ASCII, doesn't contain any
  986.     AmigaGuide keywords.
  987.  
  988.     HTNF_CLEAN - Remove the node from the database as soon as it is
  989.     closed.
  990.  
  991.     HTNF_DONE - This flag is used to indicate to AmigaGuide that the
  992.     Dynamic Node Host already took care of presenting the node, and
  993.     that there is no need for AmigaGuide to present it.  This is
  994.     useful for playing sounds, animations, or even debugging
  995.     information.
  996.  
  997.  
  998. HM_CloseNode
  999.  
  1000. Once the user has closed all occurrences of a Dynamic Node, then
  1001. AmigaGuide sends the HM_CloseNode message to the host that opened the
  1002. node.  If the Dynamic Node Host is able to close the node, then
  1003. respond with TRUE, otherwise respond with FALSE.
  1004.  
  1005. The HM_CloseNode message uses the same message structure as HM_OpenNode.
  1006.  
  1007.  
  1008. HM_Expunge
  1009.  
  1010. AmigaGuide sends this message to all Dynamic Node Hosts when the
  1011. Expunge vector of amigaguide.library is invoked, or the
  1012. ExpungeDataBases() function is called. The Dynamic Node Host should
  1013. free as much memory as it possibly can.
  1014.  
  1015. The HM_Expunge method receives the following arguments:
  1016.  
  1017.  
  1018.     /* HM_Expunge */
  1019.     struct opExpungeNode
  1020.     {
  1021.         ULONG MethodID;
  1022.         struct TagItem *oen_Attrs;    /*  R: Additional attributes */
  1023.     };
  1024.  
  1025.  
  1026. The field definitions are as follows
  1027.  
  1028.  
  1029.   oen_Attrs
  1030.   Currently, no attributes passed.
  1031.  
  1032.  
  1033. Message Dispatcher
  1034.  
  1035. The following is an example of Dynamic Node Host message dispatcher.
  1036. Since this is executed with a callback hook, it is being run on the
  1037. calling process' task, not the Dynamic Node Host process.  Because of
  1038. that, it is necessary to load the global data segment using geta4()
  1039. or __saveds.
  1040.  
  1041.  
  1042.     ULONG __saveds
  1043.     dispatchAmigaGuideHost (struct Hook *h, STRPTR db, Msg msg)
  1044.     {
  1045.         struct opNodeIO *onm = (struct opNodeIO *) msg;
  1046.         ULONG retval = 0;
  1047.  
  1048.         switch (msg->MethodID)
  1049.         {
  1050.             /* Does this node belong to you? */
  1051.             case HM_FindNode:
  1052.                 {
  1053.                     struct opFindHost *ofh = (struct opFindHost *) msg;
  1054.  
  1055.                     DB (kprintf ("Find [%s] in %s\n", ofh->ofh_Node, db));
  1056.  
  1057.                     /* See if they want to find our table of contents */
  1058.                     if ((stricmp (ofh->ofh_Node, "main")) == 0)
  1059.                     {
  1060.                         /* Return TRUE to indicate that it's your node,
  1061.                          * otherwise return FALSE. */
  1062.                         retval = TRUE;
  1063.                     }
  1064.                     else
  1065.                     {
  1066.                         /* Display the name of the node */
  1067.                         Display (onm);
  1068.  
  1069.                         /* Return TRUE to indicate that it's your node,
  1070.                          * otherwise return FALSE. */
  1071.                         retval = FALSE;
  1072.                     }
  1073.                 }
  1074.                 break;
  1075.  
  1076.             /* Open a node. */
  1077.             case HM_OpenNode:
  1078.                 DB (kprintf ("Open [%s] in %s\n", onm->onm_Node, db));
  1079.  
  1080.                 /* See if they want to display our table of contents */
  1081.                 if ((stricmp (onm->onm_Node, "main")) == 0)
  1082.                 {
  1083.                     /* Provide the contents of the node */
  1084.                     onm->onm_DocBuffer = TEMP_NODE;
  1085.                     onm->onm_BuffLen = strlen (TEMP_NODE);
  1086.                 }
  1087.                 else
  1088.                 {
  1089.                     /* Display the name of the node */
  1090.                     Display (onm);
  1091.  
  1092.                     /* Indicate that we want the node removed from our
  1093.                      * database, and that we handled the display of the
  1094.              * node */
  1095.                     onm->onm_Flags |= (HTNF_CLEAN | HTNF_DONE);
  1096.                 }
  1097.  
  1098.                 /* Indicate that we were able to open the node */
  1099.                 retval = TRUE;
  1100.                 break;
  1101.  
  1102.             /* Close a node that has no users. */
  1103.             case HM_CloseNode:
  1104.                 DB (kprintf ("Close [%s] in %s\n", onm->onm_Node, db));
  1105.  
  1106.                 /* Indicate that we were able to close the node */
  1107.                 retval = TRUE;
  1108.                 break;
  1109.  
  1110.             /* Free any extra memory */
  1111.             case HM_Expunge:
  1112.                 DB (kprintf ("Expunge [%s]\n", db));
  1113.                 break;
  1114.  
  1115.             default:
  1116.                 DB (kprintf ("Unknown method %ld\n", msg->MethodID));
  1117.                 break;
  1118.         }
  1119.  
  1120.         return (retval);
  1121.     }
  1122.  
  1123.  
  1124.  
  1125.                     DEVELOPER SPECIFIC UTILITIES
  1126.  
  1127.  
  1128. On the DevCon disks are a number of utilities for AmigaGuide that
  1129. would be of special interest to the developer.
  1130.  
  1131.  
  1132.   AD2HT
  1133.   Scans Autodocs for function and command names, scans the INCLUDE:
  1134.   directory for .h include files, and scans the include files for
  1135.   structure definitions.  Also parses Autodoc files and constructs a
  1136.   corresponding AmigaGuide database.  It resolves links to functions,
  1137.   commands, include files and structures.
  1138.  
  1139.   CXRef
  1140.   Scans a source directory and builds a cross-reference showing where
  1141.   all functions and structures are defined.  Something like ctags on
  1142.   the Sun.
  1143.  
  1144.  
  1145.  
  1146.                               GLOSSARY
  1147.  
  1148.  
  1149. Autodoc
  1150.   Documentation extracted from source code.
  1151.  
  1152. browse
  1153.   Navigate sequentially through a series of documents, instead of via
  1154.   links.
  1155.  
  1156. cross-reference table
  1157.   A table that consists of the following information:
  1158.  
  1159.   keyword
  1160.   A word or phrase
  1161.  
  1162.   database
  1163.   Name of the database that the keyword is defined in.
  1164.  
  1165.   line
  1166.   The line that the keyword is defined on within the database.  This only
  1167.   applies if the database is a straight text file (such as an include
  1168.   file).
  1169.  
  1170.   type
  1171.   What type the keyword is, such as a 'normal', function, command,
  1172.   include file, or structure.
  1173.  
  1174. database
  1175.   A file that consists of multiple documents.
  1176.  
  1177. document
  1178.   A block of text, constrained to one subject.  Also called a node.
  1179.  
  1180. Dynamic Node
  1181.   A Dynamic Node is a hypertext, or plain text, document that is
  1182.   generated in real-time, or from live data, as opposed to coming from a
  1183.   static file.
  1184.  
  1185. Dynamic Node Host
  1186.   An application that generates Dynamic Nodes.
  1187.  
  1188. link
  1189.   A word, or phrase, within a document that is linked to another
  1190.   document.
  1191.  
  1192. node
  1193.   A block of text, constrained to one subject.  Also called a document.
  1194.  
  1195. retrace
  1196.   To follow, in a reverse direction, the path taken through a series of
  1197.   documents.
  1198.  
  1199. table of contents
  1200.   A list of documents, categorized by type.
  1201.  
  1202.  
  1203.  
  1204.                          RECOMMENDED READING
  1205.  
  1206.  
  1207. "Hypertext Hands-On!" Ben Shneiderman & Greg Kearsley. Addison-Wesley
  1208. Publishing Company. ISBN 0-201-13546-9
  1209.  
  1210. "Understanding Hypertext Concepts and Applications" Philip Seyer.
  1211. Windcrest Books. ISBN 0-8306-9108-1 (hard)  0-8306-3308-1 (pbk.)
  1212.