home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 164.lha / ARexx / RefMacro_ARexx / README.ref < prev    next >
Encoding:
Text File  |  1988-04-28  |  5.4 KB  |  107 lines

  1.                 REFERENCE - An ARexx macro for TxEd Plus
  2.                 ========================================
  3.                     (if it looks icky set tabs to 4)
  4.         ( THIS MACRO PACKAGE REQUIRES THE COMPLETE AREXX SYSTEM )
  5.  
  6.     Reference will add an online lookup facility to TxEd Plus.  The 
  7. command structure and execution is functionally similar to the REFS 
  8. command in Matt Dillon's DME editor.  It allows the selective viewing
  9. of text based on a keyword specified in the file currently being edited.
  10. The macro will extract the current word (the one under the cursor) and
  11. attempt to look it up.  If the keyword is found, another TxEd window will
  12. be opened to allow viewing of the associated text.  If it is not found,
  13. an error message will be presented for your perusal.
  14.  
  15. The referencing macro consists basically of three parts:
  16. 1) the ARexx code, which drives the system,
  17. 2) the C program GetRefs which extracts the text, and
  18. 3) the reference file TxEd.refs which specifies the location of 
  19.     the referenced text.
  20.  
  21. 1) ARexx code:
  22.     The ARexx part of the referencing system comes in two parts,
  23.     reference.txed and startup.txed.  Reference.txed is a standalone
  24.     macro, while startup.txed must be added to your TxEd startup macro.
  25.     At a glance, these work as follows: you assign a macro to execute
  26.     reference.txed.  Reference.txed begins by copying the word at the
  27.     current cursor location to the macro +X (which is essentially a
  28.     scratch buffer) and then retreives the text (by a status call).  
  29.     This is the key to search on.  It then executes the c program GetRefs
  30.     which will extract the desired text if it exists.  If GetRefs 
  31.     succeeds, Reference.txed will define the constant Reference in the 
  32.     cliplist and start another TxEd process.  The new process checks to 
  33.     see if Reference is defined (in it's startup macro).  If Reference 
  34.     exists, the new process replaces the value of Reference with it's 
  35.     own ARexx port address.  Meanwhile, Reference.txed has waited a 
  36.     sufficient (?) amount of time for it's child to come to life.  It then
  37.     retreives the child's address from the Cliplist and undefines the
  38.     variable Reference.  Then it sends several messages to both the
  39.     child and the original TxEd process, moving windows, loading text
  40.     etc.  Then the ram scratch file is deleted (to be nice and neat). 
  41.     The macro then exits, leaving the original TxEd as the active
  42.     window.
  43.  
  44. 2) GetRefs
  45.     This is a fairly simple C program that accepts one command line
  46.     argument, which is the keyword to search for.  It attempts to open
  47.     the text file TxEd.refs in df1:s,df0:s,ram:s in that order.  If it
  48.     succeeds, it searches for the keyword.  If the keyword is found, it
  49.     gets the search file name and the start and end text from the .refs
  50.     file.  Then it opens the search file, searches for the start text
  51.     and (if it exists) copies all text between the start text and the
  52.     end text to a scratch file in ram.  (Specifically, to ram:extract.txt)
  53.     
  54.     There is much room for improvement in this program which is why I
  55.     included the source code.  I have taken very little time to optimize
  56.     it, but then, I started out writing it in ARexx which was much slower
  57.     than C.  Currently, a worst case reference extraction takes about
  58.     30 seconds, but there is a lot of text to search (about 15K of
  59.     TxEd.reference, then who knows how much in the search file).  I have
  60.     not benchmarked this extensively, it's fast enough for the moment.
  61.  
  62. 3) TxEd.refs
  63.     This is an ascii text file which defines the valid keywords.  It has
  64.     a format like this:
  65.     Keyword        "end string"    search-file-name    "start string"
  66.     where search-file-name is the file (complete path please) that contains
  67.     the explanatory text for keyword.  This text is located in the file
  68.     between the start and end strings inclusive.  As an example, I have
  69.     included two TxEd.refs files, one from my autodocs disk and one from
  70.     my commented includes disk.  It is possible to have more than one 
  71.     TxEd.refs file, but currently they must be on different disks (logically
  72.     enough, I put them in an S directory on the disk that contains the
  73.     search files)
  74.  
  75.     The start string must be a regular printable ascii string, no control
  76.     characters or newlines are allowed.  The quotes are optional, but if
  77.     the string contains any whitespace they must be included.  The same
  78.     rules apply for the end string, except that an end string of "^L"
  79.     will be taken to mean 'stop at the next formfeed'.  This is handy for
  80.     referencing the autodocs.    
  81.  
  82.  
  83. To run the system, rename the file refer.txed -> reference.txed and
  84. put it in the REXX: directory.  Add the lines in startup.txed to your
  85. TxEd startup macro.  Put getrefs in the C: directory.  Make your 
  86. TxEd.refs file in the appropriate form and put it in the s directory
  87. of the reference disk.  (Feel free to use mine, just rename the appropriate
  88. file as TxEd.refs and be sure that the filenames agree with those on
  89. your autodocs or includes disks - then put the .ref file in the s directory
  90. of the appropriate disk).  You can change the macro assignment for 
  91. referencing if you wish, I currently have it assigned to F3.
  92. When all this is done, just run txed, move the cursor to the word that
  93. you wish to reference and hit the F3 key.  Away you go...
  94.  
  95. Well, that's about it I guess, change what you want, keep the rest
  96. or chuck the whole mess.  Hope you find it useful, I certainly do.
  97. It adds a very nice feature to a marvelous editor and ARexx is a 
  98. pleasure to use (Thanks cheath and whawes).
  99.  
  100. If you have any problems, please let me know. (suggestions also)
  101.  
  102. John Hardie
  103. BIX: jhardie
  104. USENET: jgh2@unix.cis.pittsburgh.edu
  105.  
  106.  
  107.