
      [43m           [40m
      [43m HyperBook [40m
      [43m           [40m
                 [42m                                         [40m
                 [42m  Run [43myour own macros[42m in the reduced     [40m
                 [42m  HBReader version, before you graduate  [40m
                 [42m  to the full HyperBook program          [40m
                 [42m                                         [40m

                            [[3;33mby John Collett[0m



[32m   <> 34 <%> 34 <%> 34 <%> 34 <%> 34 <%> 34 <%> 34 <%> 34 <%> 34 <%> 34 <>
[0m

    Only by writing macros in HML (HyperBook Macro Language) can you
    harness the full strength of HyperBook, and tap into the virtually
    unlimited power of ARexx from within a HyperBook unit.  Only with the
    full HyperBook program do you have access to the macro editor.  The
    smaller versions called HBReader and HBBrowser do not allow it.

    But here is an arrangement which makes it possible to use plain ASCII
    texts as scripts for macros to be used in HBReader. The full HyperBook
    program is not required.

    This article and the accompanying HyperBook script called Runner.HB is
    intended for readers who :

     - Do not already have HyperBook.
     - Like what they have seen and heard about it so far.
     - Want to know a bit more about it before they decide to buy it.
     - Would like to explore it more deeply than the HBReader version of
       the program on its own normally allows.

    This will not and is not intended to give you a free, backdoor access
    to the full range of HyperBook facilities.  What it will do is allow
    you to write and run some HyperBook macros of your own, which is not
    normally possible from HBReader.  It will provide you with nothing
    like the power, range, and convenience of HyperBook itself, so do not
    even begin to think that this little exploratory device will save you
    the expense of buying the real thing.

    In any case, if you haven't got HyperBook, you haven't got its User
    Manual.  In that case you won't know the syntax of the 137 commands of
    the HyperBook Macro Language.  So you won't be able to write macros
    anyway, because you won't know how to.  The Manual is part of what you
    pay for when you buy it.

    I'll be giving just a few small and tempting samples here for you to
    copy and explore.  I hope they'll be enough to interest you, to give
    you a good idea of what can be done, and to encourage you to buy
    your copy of HyperBook.

    I have no vested interest in GoldDisk, HyperBook, or its authors'
    retirement fund.


    [42m  Running Runner.HB  [40m

    Doubleclick on the Runner.HB gadget (it requires HBReader to be in
    the same directory).

    On Runner.HB's first and only screen you will see a 'Run' gadget in
    the top left corner.  Click on it.  You will be presented with a file
    requester.  Choose the file you wish to run as a macro, for example,
    one of the samples provided below.  Assuming that you choose the
    correct type of file (plain ASCII text), that it is in the current
    directory, and that its syntax is correct, it will behave as if it were
    an orthodox macro created in HyperBook's built-in macro editor to which
    you do not have access from HBReader.

    All sorts of problems are avoided if the file holding the script is in
    the same directory as HBReader and Runner.HB.  I tried getting round
    those problems and did eventually manage it, but the solution hardly
    justified the quantity of code it required, and so I removed it.

    [42m  How it works  [40m

    The 'Run' gadget activates an already-existing internally-held macro
    called 'readsource' which you cannot read or edit from HBReader. This
    macro presents the file requester, opens the file you choose (from the
    current directory only, remember), and uses the magic ARexx instruction
    'interpret' to execute the script as if it were normal ARexx program
    code or regular HyperBook macro code.

    Use the 'Quit' option from the menu when needed.

    ----------------------------------------------------------------------
    [4mPossible alternative approaches[0m

    I have done a fair amount of exploring before coming up with this
    final arrangement, and a few compromises have been made.

    1  Instead of a visible 'Run' gadget, the 'readsource' macro could
    have been called, say, 'F1_readsource', and it could then have been
    called by pressing Right Amiga and the F1 key.  I have two things
    against this :
      (a)  I like visible gadgets on the screen.  They save me having to
           remember which combinations of keys to press.
      (b)  I may be wrong, but I don't think the 'Fn_' prefix works as a
           way of calling a HyperBook macro if you already have AutoCLI
           running, which I always do.

    2  One well-concealed paragraph in the manual says that macro scripts
    can be held in the 'rexx:' directory instead of internally in a
    HyperBook unit.  I explored this alternative method of supplying macros
    for HBReader and it looked promising.  Try it if you like. It did have
    one or two advantages over the method I finally adopted, but ...

    ----------------------------------------------------------------------


    [42m  A few tempting samples  [40m

    Each of these short scripts can be lifted out of this text and stored
    separately, ready for use by Runner.HB.  Call each one whatever you
    like, but they must be stored in the same directory as HBReader and
    Runner.HB (sorry to keep on about that point).
    Explore the effects of changing details within the script.

      [32m/*  Macro sample 1  Creating a note containing text */
      [32ma = "This macro will create a 'Note' containing"
      [32mb = "this text. Its 'Action' (what it does when"
      [32mc = "you click on it) will be to delete itself."
      [32mtext = a || '0a'x || b || '0a'x || c
      [32mnote = CreateNote() ; call InsertText(note,text,0)
      [32mcall ScaleToSize(note,370,32) ; call SetPosition(note,50,40)
      [32maction = SetActionRexx(note,'call HML_Delete(initiator())')
      [32mnewpos = Relocate(note,':')
      [32m/* End of sample 1 */

    [4mSome of the things you can change or add are[0m

      The text in the note
      The size and position of the note
      The note's background colour, e.g. colour = SetBackGround(note,3)
      Border colour, e.g. border = SetBorder(note,2)
      Shadow colour, e.g. shadow = SetShadow(note,1)
      Shadow style(embossed or dropshadow), e.g. s = ShadowStyle(note,2)

    [4mWhat cannot be changed without the full editing facilities[0m

      Text colour (unless you change the RGB setting of the colour of
                   the text; that could be done!)
      Text style (italics, bold, etc.) and font
      Text spacing (between letters and rows)
      Exact vertical and horizontal location of text within the box

                       -----------------

      [32m/*  Macro sample 2  A note with user-supplied text */
      [32ma = "Enter text to appear in the note"
      [32mtext = InputString(a,'')
      [32mnote = CreateNote() ; call InsertText(note,text,0)
      [32mcall ScaleToSize(note,length(text)*8 + 24,16)
      [32mcall SetPosition(note,50,40)
      [32maction = SetActionRexx(note,'call HML_Delete(initiator())')
      [32mcolour = SetBackGround(note,2) ; border = SetBorder(note,3)
      [32mshadow = SetShadow(note,1) ; style = ShadowStyle(note,2)
      [32mnewpos = Relocate(note,':')
      [32m/* End of sample 2 */

    Sample 2 includes some of the extras mentioned above.  When the
    InputString requester appears for you to insert your text, check that
    the mouse pointer is over the empty text bar before you begin typing. I
    was surprised to find that the authors of HyperBook had not made such a
    check unnecessary.  Since the note box is set to be only 12 pixels
    deep, be sensible about the length of the text you enter.  If you make
    it longer than the width of the box allows, it will be wrapped
    automatically, and it will need a deeper box.

                       -----------------

      [32m/*  Macro sample 3   Creating a 5-item list */
      [32ma.1 = "Sort this list" ; a.2 = "Change item colour"
      [32ma.3 = "Change item text" ; a.4 = "Add another item"
      [32ma.5 = "Delete this list"
      [32mlist = CreateList()
      [32mdo i = 1 to 5 ; item = AppendItem(list,a.i,1) ;end
      [32mthis = list || '/' || i
      [32ma = "call Sortlist('List1'())"
      [32m    act = SetActionRexx(list || '/1',a)
      [32ma = 'c=SetItemColor(initiator(),3)'
      [32m    act = SetActionRexx(list || '/2',a)
      [32ma = 'o=SetItemText(initiator(),"A new text")'
      [32m    act = SetActionRexx(list || '/3',a)
      [32ma = 'i = AppendItem('List1'(),"Added item",1)'
      [32m    act = SetActionRexx(list || '/4',a)
      [32ma = "call HML_Delete('List1'())"
      [32m    act = SetActionRexx(list || '/5',a)
      [32mcall ScaleToSize(list,200,64) ; call SetPosition(list,150,40)
      [32mlist = Relocate(list,':')
      [32m/* End of sample 3 */

    Each of the items in the list has a specific action, as indicated by
    their text.  If you click on them, they do what they are set to do.
    The punctuation for the five 'SetAction' entries was a bit tricky!

                       -----------------

      [32m/*  Macro sample 4   A separate ARexx program  */
      [32mcall HyperBookToBack()
      [32mop = open('con','con:30/30/500/120/A Program/CLOSE')
      [32mtab = '09'x ; lf = '0a'x || tab
      [32ma = lf || 'This is a small but complete ARexx program'
      [32mw = writeln('con',a)
      [32ma = tab || 'which opens a console, prints these lines,'
      [32mw = writeln('con',a)
      [32ma = tab || 'and then waits for you to press Return.'
      [32mw = writeln('con',a || lf)
      [32ma = lf || 'Before and after, the HyperBook screen is'
      [32mw = writeln('con',a)
      [32ma = tab || 'pushed to the back and then brought forward.'
      [32mw = writeln('con',a)
      [32mw = writeln('con',lf || tab || 'Press Return now ')
      [32mr = readch('con',2)
      [32mcl = close('con')
      [32mcall HyperBookToFront()
      [32m/* End of sample 4 */

    I should have said so earlier, but of course you must have ARexx up
    and running in the background before [4many[0m HyperBook macro will
    work.

                       -----------------

      [32m/*  Macro sample 5   HyperBook 'Drawing's  */
      [32mdo d = 1 to 6
      [32m  d.d = SearchName(':','Drawing' || d) ; call SetVisibility(d.d,1)
      [32m  call SetPosition(d.d,100+20*d,10 + d * 25)
      [32m  end
      [32mcall pause(20)
      [32mdo d = 1 to 6
      [32m  w.d = GetWidth(d.d) ; h.d = GetHeight(d.d)
      [32m  call ScaleToSize(d.d,100,50) ; end
      [32mcall pause(20)
      [32mdo d = 1 to 6 ; call ScaleToSize(d.d,w.d,h.d) ; end
      [32mcall pause(20)
      [32mdo d = 1 to 6
      [32m call SetVisibility(d.d,0) ; call SetPosition(d.d,1,10 + d * 20)
      [32m end
      [32m/* End of sample 5 */

    Not much can be accomplished in the way of drawings without the
    built-in HyperBook drawing editor.  There is no way you can create a
    drawing of your own, and Sample 5 really is a bit pointless, but it may
    just whet your appetite for the real thing. It contains four 'do ...
    end' loops.
                                                              __
    1  Identifies six ultra-simple drawings ( | - /  \ O and |__| ) which
       are on Page 1, but stored invisibly. Makes them visible and places
       them left of centre on screen.
    2  Stores their sizes.   Changes their sizes.
    3  Restores them to their original size.
    4  Makes them invisible, and parks them out of the way.

    Sample 5 does at least show [4msome[0m of the things that can be done
    with drawings, and you might like to explore copying, resizing, and
    combining the elements provided into real little sketches.  A copy can
    be made by using a command such as 'd.7 = Clone(d.1,':')', which would
    make a copy of the drawing identified as 'd.1' in the first loop, call
    it d.7, and place it on the current page.

                       -----------------

    I'm not even going to try to achieve anything with a 'Picture'
    in the restricted environment of Runner.HB.  I could only repeat what I
    have just tried with drawings : provide a sample, and let you copy
    or resize it.

                       -----------------

      [32m/*  Sample 6  Playing with buttons */
      [32mdo i = 1 to 4
      [32m  but.i = CreateButton()
      [32m  call ScaleToSize(but.i,40,20) ; call InsertText(but.i,i,0)
      [32m  call SetPosition(but.i,50 + i*80,40) ; but.i = Relocate(but.i,':')
      [32m  end
      [32mact = SetActionShow(but.1,but.2)
      [32mact = SetActionShow(but.2,but.1)
      [32mact = SetActionShow(but.3,but.1)
      [32ma = "call HML_Delete('Button1'());call HML_Delete('Button2'())"
      [32mb = "call HML_Delete('Button3'());call HML_Delete('Button4'())"
      [32mact = SetActionRexx(but.4,a || ';' || b)
      [32m/*  End of Sample 6  */

    Four buttons whose actions are set.  Explore by clicking on them.
    Button 4 deletes all of them.

                       -----------------

               Explore, learn, enjoy.    Then buy.

    [33;3mHamilton, New Zealand  May, 1993[0m

                    --------------------------

[32m   <> 34 <%> 34 <%> 34 <%> 34 <%> 34 <%> 34 <%> 34 <%> 34 <%> 34 <%> 34 <>
[0m

