home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 1 / RISC_DISC_1.iso / pd_share / code / morehelp / !MoreHelp / !Help < prev    next >
Encoding:
Text File  |  1994-08-27  |  18.7 KB  |  384 lines

  1. More Help version 1.00
  2. © Sam Kington 27th August 1994
  3. This program is freeware, *not* public domain – i.e., I retain copyright (see
  4. “Boring legal message”).
  5. This module will only work with RISC OS 3 or later.
  6.  
  7. What this program does
  8. **********************
  9.  
  10.    This program, or more accurately this module, allows you to add
  11. interactive help to programs that don’t usually give interactive help. The
  12. actual mechanism is quite intricate, but basically you tell the program to
  13. catch all the requests for interactive help going to a particular help, and
  14. to reply with messages contained in a supplied text file. The actual format of
  15. the text file is available later on in this file.
  16.  
  17. Why is this useful?
  18. *******************
  19.  
  20.    First of all, it allows you to quite easily add interactive help to
  21. programs – which is undeniably a good thing, especially for new users, but
  22. also for people trying out your work of art in a hurry, and ready to discard
  23. it if they can't immediately understand how it works, which is the case with
  24. most people going through their new discs full of freeware.
  25.  
  26.    Secondly, as both code and messages are held in the module area it doesn't
  27. eat up your precious WimpSlot. If you're struggling to keep something just
  28. inside a 32K WimpSlot, for instance, you don't want the WimpSlot to double to
  29. 64K just so you can have these nice helpful messages. This doesn’t mean
  30. you’re not using the memory – you are, there’s no miracle – but it’s slightly
  31. less wasteful.
  32.  
  33.    Thirdly, the help is held in a quite easily-edited text file and can be
  34. removed by commenting-out a few lines in the !Run file. Other interactive
  35. help providers like the Interface or WimpExt modules expected the help text
  36. to be held in the validation strings, which meant the help strings weren't as
  37. long as they could have been, and also made the Templates file positively
  38. massive, which means a big buffer in application space - and bang goes the
  39. WimpSlot again.
  40.  
  41.    Fourthly, you can add interactive help to programs without changing a
  42. single line of code (apart from the !Run file, and they get changed quite a
  43. bit anyway) - you don’t have to re-compile or re-crunch them, you just have
  44. to write the file. This also means that people who are fed up with there not
  45. being interactive help can add it themselves, then send it off to you for you
  46. to distribute.
  47.  
  48.    Finally, as this is a module, available to all programs, the code for
  49. decoding interactive help messages isn’t duplicated across programs – and
  50. the module is small enough for people not to worry about having it loaded.
  51. The more programs use it, the larger the savings are – so distribute it like
  52. crazy, use it in your own programs, and make More Help files for programs that
  53. don’t provide interactive help!
  54.  
  55.    Evangelistic mode off ;)
  56.  
  57. The message file format
  58. **********************
  59.  
  60.    If you want to know how the program works, for instance so you can use it
  61. on your own programs or add help messages to other people’s, you’ll need to
  62. know about Message files, as used by MessageTrans. Skip this section if you
  63. already do, or if you feel confident enough to pick it up as you go along;
  64. bear in mind, however, that the “How it works” relies to some extent on you
  65. having read this section.
  66.  
  67.    If you don’t know what message files look like, the best way to find out is
  68. to look at Text files called Messages or something similar, inside application
  69. directories. A good place to start is the Resources filing system,
  70. Resources:$.Resources (Choose “Open $” from the Apps icon bar menu, open the
  71. directory Resources) – all the directories contain Messages files. ADFSFiler
  72. in particular contains wildcarded tokens, AppDraw demonstrates linking one
  73. message to several tokens. Doubtless there are others, I stopped at AppDraw.
  74. (Guess how I was sorting the Filer window? ;) )
  75.  
  76.    But enough of this gibberish, what does it all mean? Well, if you’ve had a
  77. look at Messages files, you’ll see they’re actually human-readable text files,
  78. with lots of lines looking something like this:
  79.  
  80. SetI7:\Ssubstitute double quotes as open and closed double quotes.
  81.  
  82.    The important bit in this line is the “:” character: the stuff to the left
  83. is the programmer-friendly “token”, the stuff to the right is the actual
  84. message that, presumably, the user will see at one point or another
  85. (although, as lots of message files contain almost nothing but errors, you may
  86. not *want* to see the message). When the program asks for message code
  87. “SetI7”, MessageTrans looks through the file for the token “SetI7”, which will
  88. usually be at the beginning of a line. It then carries on looking through the
  89. file until it finds a colon (“:”), which will usually be directly after the
  90. token. It then reads the text between the colon and the next newline (i.e.
  91. line break), and returns this as the user-friendly message.
  92.  
  93.    To get rid of the first complications, you may notice that although the
  94. Messages files are full of things like “\S”, you never see such a character
  95. combination when the messages are actually displayed. In case, “\S” is just
  96. one of several special abbreviation codes used to keep message files
  97. slightly shorter – much like abbreviations in Impression, they are expanded
  98. automatically when the message is read. The list of abbreviation codes in
  99. RISC OS 3.1 (I don’t think it has changed in RISC OS 3.5) is as follows:
  100.       \S:“Click SELECT to ”
  101.       \R:“Move the pointer right to ”
  102.       \A:“Click ADJUST to ”
  103.       \T:“This is the ”
  104.       \G:“This option is greyed out because ”
  105.       \W:“This window is ”
  106.       \D:“Drag SELECT to ”
  107.       \d:“Drag ADJUST to ”
  108.       \w:“window”
  109.       \s:“SELECT”
  110.       \a:“ADJUST”
  111.    Obviously the quote marks aren’t part of the message; also note the
  112. trailing spaces, so that “\Ssubstitute quotes” is actually displayed as
  113. “Click SELECT to substitute quotes”. A common mistake is to forget that “\S”,
  114. “\R”, and other such abbreviations include a “ to ”: “\S to substitute
  115. quotes” would actually be displayed as “Click SELECT to  to substitute
  116. quotes”. Also note that there is no “\M” or “\m” – MENU nearly always brings
  117. up a menu so there is usually no need to support interactive help about it.
  118.    The actual list of tokens is contained in Help’s Messages file, in
  119. Resources:$.Resources.Help in RISC OS 3.1 (somewhere else in RISC OS 3.5 I
  120. think).
  121.  
  122.    Messages files do not just contain lines with one token and one message:
  123. sometimes there will be several tokens for one message, or wildcarded tokens.
  124. An example, again from the Smart Quotes help file, is for the “miscellaneous”
  125. icons of the “Settings (as icons)” window:
  126.  
  127. SetI?/SetI??/SetIW:\Tsettings window, using icons at the moment, where you
  128. can turn various character substitutions on and off. Use the Characters
  129. window to change the characters used as quotes, or the Diphthongs window to
  130. view and edit the list of diphthongs.
  131.  
  132.    Clearly, the message is found if you look for “SetIW”; it is also found
  133. for tokens “SetI?” and “SetI??”. The message could also have been defined like
  134. this:
  135.  
  136. SetI?
  137. SetI??
  138. SetIW:\Tsettings window, using ...
  139.  
  140.    In other words, a newline (line break) or a “/” (NB: do not confuse with
  141. “\”, used for abbreviations) will tell the operating system that there are
  142. several tokens that should return the same message. All the tokens after
  143. the previous message, and before the colon (“:”), will be found and will
  144. return the message after the colon.
  145.  
  146.    A last complication is the wildcard character, “?”. This will match any
  147. one character (apart from the special ones like :, \ etc.), and one
  148. character only, much like the blank square in Scrabble: in this case, the
  149. “This is the settings window” message will be returned for tokens “SetI5”,
  150. “SetI22”, “SetI05” but *not* “SetI” or “SetI22S”.
  151.    Note that, because although several tokens can match one message, one
  152. token cannot match several messages (that would be silly), so as soon as a
  153. match has been found MessageTrans stops searching the file. This means that,
  154. first of all, messages at the beginning of the file will be found slightly
  155. faster (the difference is quite trivial), and secondly, wildcarded messages
  156. should always be after all other similar messages. In other words, if you
  157. want special messages for tokens “SetI5”, “SetI10” and “SetI16”, but want to
  158. use the same one for all messages of the form “SetI?” or “SetI??” or “SetIW”,
  159. the message file should look like this:
  160.  
  161. SetI5:message1
  162. SetI10:message2
  163. SetI16:message3
  164. SetI?/SetI??/SetIW:This is the default message
  165.  
  166.    Finally, because MessageTrans looks for a newline (line break) after a
  167. message, there should be one after the last message, otherwise it won’t be
  168. found.
  169.  
  170. How it works
  171. ************
  172.  
  173.    MoreHelp has three commands for you to use:
  174.       • MoreHelp_AddTask         <task name> <message file>
  175.       • MoreHelp_RemoveTask      <task name>
  176.       • MoreHelp_AddHelpMessages
  177.    AddTask will set up a filter on the specified task, and load a Messages type
  178. file (that is, a Text file, type &FFF, with a list of tokens and message inside
  179. – see above) containing the help messages: the task will now appear to give
  180. interactive help. (It isn’t, of course, More Help is, but the point of all
  181. this is that you don’t know). The task name is the name that appears in the
  182. Task Manager window. If it contains spaces, put it in quotation marks, so you
  183. would type *MoreHelp_AddTask "Smart Quotes" SmartQuote.
  184.  
  185.    RemoveTask will remove the specified task, messages will no longer be
  186. intercepted and interactive help will stop.
  187.  
  188.    AddHelpMessages will make the *last task to be added* “know” about Help
  189. messages – this is because under RISC OS 3 tasks can ask to only be told
  190. about certain messages, so will often not receive the Help messages if they
  191. preferred not to. The command should only be run once, because otherwise
  192. strange effects can happen (not my fault, I don’t think), and the best bet is
  193. to run it immediately afterwards AddTask. As a rule of thumb, run it *once*
  194. if a program isn’t producing interactive help despite your carefully honed
  195. Messages file.
  196.  
  197.    If you do a *Filters from the command line (F12 or Ctrl-F12) you will see
  198. how More Help operates. It sets up a filter for each of the tasks that have
  199. had interactive help added with AddTask, to intercept interactive help
  200. messages. In addition, it sets up another filter on all tasks, to intercept
  201. Close Down messages – messages sent out when a task closes down – so it can
  202. remove its filter when the task it is supplying help to quits.
  203.  
  204.    When it gets a help message, it finds the title of the window the pointer
  205. is over, strips spaces from it and replaces certain characters to avoid
  206. using forbidden characters (see below), then looks in the supplied message
  207. file for the corresponding message. For instance, if you asked for help on a
  208. window whose title was “Settings (as icons)”, it would look for a message
  209. token in the file called “Settings{asicons}”. It would then find the message
  210. corresponding to the particular token, and use that as the window code. The
  211. Smart Quotes interactive help file contains the following line:
  212.  
  213.       Settings{asicons}:SetI
  214.       
  215.    So, if you held the pointer over the window entitled “Settings (as
  216. icons)”, the window code would be “SetI”. If this line wasn’t in the file for
  217. some reason, the window code would default to “UK” (unknown, not United
  218. Kingdom ;) ).
  219.  
  220.    The forbidden characters are as follows:
  221.       , replaced by .
  222.       ) replaced by }
  223.       : replaced by ;
  224.       ? replaced by !
  225.       / replaced by \
  226.       ( replaced by {  (for neatness' sake)
  227.        
  228.    If you hold the pointer over the icon bar, More Help will pretend the
  229. window title was in fact “Iconbar”, so if the following line was in the
  230. message file:
  231.  
  232.       Iconbar:Ibar
  233.       
  234. the window code would be “Ibar”.
  235.  
  236.    If the pointer is over a menu, it will look for the token corresponding to
  237. the window the pointer was over when MENU was clicked, and add “M” to it, so
  238. if the pointer is over the menu produced by clicking MENU on the Icon bar,
  239. the window code will be “IBarM”.
  240.  
  241.    It will then add the icon number or the menu entry to the code, which
  242. would then look something like “SetI22” or “IBarM2”, if the pointer was over
  243. icon number 22 in the “Settings (as icons)” window, or the third entry in the
  244. icon bar menu – the first option is in fact option 0. Because menus are
  245. hierarchical, it will in fact add the numbers of all the menu options
  246. currently highlighted, so if the pointer was over the first option of the first
  247. submenu of the fifth option on the menu opened from a window with the token
  248. “Main” (for instance, “Display.Font.System Font” in Edit’s main menu), the
  249. resulting token would be “MainM400”. Each menu number will be exactly one
  250. character long, to avoid confusion, which means that when we get to the
  251. eleventh menu entry there could be problems. To work out the character used
  252. for the menu entry, More Help does the following:
  253.    For numbers 0-9, it uses characters “0” to “9”
  254.    For numbers 10-35, it uses characters “A” to “Z”
  255.    For numbers 36-71, it uses characters “a” to “z”
  256.    For numbers 72-134, it uses characters “À” to “þ”
  257.    This is really overkill: if you have a menu this long it’s probably either
  258. a list of fonts, a list of modules, or some other list that More Help cannot
  259. possibly know about – certainly there should be no need to supply *distinct*
  260. help messages for each entry. If you do want to provide help, say for
  261. MainM3420 to MainM342Z (or whatever), the best bet is to provide a single
  262. token, MainM342?.
  263.  
  264.    If the pointer is over the window’s work area, it will instead add a “W”.
  265.  
  266.    Finally, it will look at the icon to see whether it is selected or greyed
  267. out. If it is selected (only for icons) it will add a “S” to the token, if it
  268. is greyed out (only for menu items) it will add a “G”. It is not possible to
  269. have both.
  270.  
  271.    Finally, it will look for this token in the message file, and return the
  272. corresponding message, which will then be used as interactive help.
  273.  
  274. Limitations
  275. ***********
  276.  
  277.    Because More Help works out what window it’s looking at by reading the
  278. title, if the title changes (for instance if it’s a pathname of a file) it
  279. will be impossible to define the appropriate token. You should instead define
  280. messages using the “UK” window code, which is the default code More Help
  281. will use if it can’t find the right token. If there are no windows like that,
  282. you should have the following like in the message file:
  283.  
  284. UK?/UK??/UK??/UK???/UK????:
  285.  
  286.    NB: there is nothing after the colon, except a newline (line break).
  287.    If there are several different types of window, with varying titles,
  288. despair.
  289.  
  290.    Similarly, interactive help won’t be as “intelligent” as it would be if
  291. the program itself was supplying it: you won’t get things like “Move the
  292. pointer right to perform an operation on ‘!MHelpEd’” because More Help
  293. doesn’t know you clicked MENU over the application !MHelpEd. If you need
  294. complicated help like that, either write your own routines if you’re
  295. programming the application yourself, or, as before, despair.
  296.  
  297. Boring legal message
  298. ********************
  299.  
  300.    This application is freeware, that is, it can be distributed freely as
  301. long as only reasonable charges are made for media and distribution. I retain
  302. copyright on all program code and documentation.
  303.  
  304.    This software is supplied “as is”: I make no warranty, expressed or
  305. implied, of the merchantability of this software or its fitness for any
  306. particular purpose. In no circumstances shall I be liable for any damage,
  307. loss of profits, or any indirect or consequential loss arising out of the use
  308. of this software or inability to use this software, even if I have been
  309. advised of the possibility of such loss.
  310.  
  311.    In other words, if your computer crashes, blows up, you lose all your work
  312. etc. all because of More Help (unlikely I know), don’t blame me. I will,
  313. however, do my best to solve bugs, add features, answer queries etc. – but
  314. bear in mind that I don’t have access to Acorns at University (term-time).
  315.  
  316. Distribution
  317. ************
  318.  
  319.    This is freeware, so you can distribute this freely – and indeed I
  320. encourage you most strongly to do so. However, because I retain copyright
  321. and I want everyone to have all the files, when you distribute the
  322. !MoreHelp application you must distribute all files intact, including source
  323. code and this documentation, with this package – in other words, the files
  324. !Boot, !Run, !Sprites, !Sprites22, MoreHelp, ModSource, !Help, and Vsn100.
  325. Feel free to muck around with it as much as you like when it’s on your
  326. machine, but distribute the original files, please.
  327.  
  328.    You are strongly encouraged to use MoreHelp in your own programs, or to
  329. write MoreHelp help files for other programs – I have plans for a MoreHelp
  330. editor and possibly an application patcher to make this sort of thing easier.
  331. However, the most time-consuming part of writing a message file is actually
  332. writing the helpful messages (or so I find anyway), so that isn’t *much* of a
  333. problem.
  334.  
  335. About all these strange foreign characters in this file
  336. ******************************************************
  337.  
  338.    OK, so if you’re reading this on a PC or a Mac or another strange machine
  339. like that, you may be wondering what all these strange ae things are. Well,
  340. they’re quotes (sorry, there was another one), dashes, ligatures, etc.
  341. Honest. But not on all machines...
  342.    Basically, character sets are only standard up to character 127, which is
  343. basically alphanumerics and a few standard punctuation marks. Foreign
  344. characters, typographical oddities like quotes and ligatures, and other more
  345. obscure symbols are “non-standard”, and each computer often has its own idea
  346. of where they should go in the character set. So don’t worry: even if it’s
  347. hard to read on your current machine, it won’t be on an Acorn machine. It may
  348. look slightly strange if you’re using the System font, however.
  349.    But why am I using these strange characters in the first place? Well,
  350. they’re in the character set and they look nice in an outine font, and I’ve
  351. written a program called Smart Quotes (sorry for the plug) that substitutes
  352. these sort of characters automatically, and I’ve got it turned on at the
  353. moment...
  354.  
  355. How to contact me
  356. *****************
  357.  
  358. All bug-reports, suggestions, comments or indeed any feedback at all will be
  359. welcomed. Here’s how to get to me:
  360.  
  361. E-mail     : 9262861k@arts.gla.ac.uk, 926286ki@udcf.gla.ac.uk during term-time
  362.              These should be OK until June 1996
  363.              At Christmas, Easter and during the summer, you can get me at
  364.              wombat@altern.com, wombat@email.teaser.com or sam@altern.com, in order
  365.              of preference (that is, if mail bounces off one of these or I don’t
  366.              answer within a week send to the next one)
  367.  
  368. Snail-mail : My term-time address, at least until June 1995, is:
  369.              Sam Kington
  370.              Flat 2/1
  371.              44 Hotspur Street
  372.              Glasgow G20 8NL
  373.              SCOTLAND
  374.              
  375.              Again, a backup is the home address – anything that goes here will get
  376.              to me eventually.
  377.              Sam Kington
  378.              Merlhiot
  379.              24420 Savignac les Eglises
  380.              FRANCE
  381.  
  382. Term-time is October to June, with bits off at Christmas (3 weeks) and
  383. Easter (4 weeks).
  384.