home *** CD-ROM | disk | FTP | other *** search
/ ftp.uni-stuttgart.de/pub/systems/acorn/ / Acorn.tar / Acorn / riscos / problems / messagedoc < prev    next >
Text File  |  1992-02-24  |  12KB  |  294 lines

  1. Article 4858 of comp.sys.acorn:
  2. Path: rusmv1!news.belwue.de!ira.uka.de!Sirius.dfn.de!darwin.sura.net!haven.umd.edu!ames!elroy.jpl.nasa.gov!swrinde!mips!mips!munnari.oz.au!comp.vuw.ac.nz!actrix!tornado!khantazi!banksie
  3. From: banksie@khantazi.welly.gen.nz (Philip R. Banks)
  4. Newsgroups: comp.sys.acorn
  5. Subject: Re: Message Translation Query
  6. Message-ID: <0T6rAzj011n@khantazi.welly.gen.nz>
  7. Date: 19 Feb 92 05:53:57 GMT
  8. References: <8377@baird.cs.strath.ac.uk>
  9. Reply-To: banks_p@kosmos.wcc.govt.nz
  10. Organization: My Arc.
  11. Lines: 271
  12.  
  13. sproven@cs.strath.ac.uk (Simon B Proven IE2) writes:
  14.  
  15. > I'd like to know more about this module if anyone can fill me in,
  16. > and if it's available under R02?
  17.  
  18.    MessageTrans is available under RO2 and behaves identically (as far as I
  19. am aware) to the RO3 version. The docs for it were released a while ago on
  20. the net so I'll repost em below for you...
  21.  
  22. ---docs begin---
  23. X-NEWS: vuwst1 comp.sys.acorn: 862
  24. Relay-Version: VMS News - V6.0-2 04/02/91 VAX/VMS V5.3; site matai.vuw.ac.nz
  25. Path: matai.vuw.ac.nz!comp.vuw.ac.nz!waikato.ac.nz!decwrl!elroy.jpl.nasa.gov!swrinde!cs.utexas.edu!uunet!mcsun!ukc!acorn!RMokady
  26. Newsgroups: comp.sys.acorn
  27. Subject: Re: MessageTrans
  28. Message-ID: <5799@acorn.co.uk>
  29. From: RMokady@acorn.co.uk (Ran Mokady)
  30. Date: 13 Mar 91 16:31:35 GMT
  31. Sender: rmokady@acorn.co.uk
  32. References: <+GG&9-$@warwick.ac.uk>
  33. Distribution: comp
  34. Organization: Acorn Computers Ltd, Cambridge, England
  35. Lines: 243
  36.  
  37. In article <+GG&9-$@warwick.ac.uk> maumg@warwick.ac.uk (Pop Mobility Freak) writes:
  38.  
  39. >
  40. >P.S.    Perhaps someone in Acorn would like to fill in the blanks and correct
  41. >        any errors I made in the above.
  42.  
  43.  
  44. We do read this group here at Acorn you know...
  45.  
  46.                         Ran.
  47.  
  48.  
  49.  
  50.  
  51. As requested here is the MessageTrans documentation. 
  52.  
  53.  
  54. Overview
  55. --------
  56.  
  57. This document describes the SWI interface to the MessageTrans module, which
  58. provides message translation services, and the format of the message files
  59. that it uses.
  60.  
  61.  
  62. SWI MessageTrans_FileInfo
  63.    In   R1 -> filename
  64.    Out  R0 = flag word:
  65.              bit 0 set => file is held in memory (can be accessed directly)
  66.              bits 1..31 reserved (ignore them)
  67.         R2 = size of buffer required to hold file
  68.              if R0 bit 0 set, the buffer is not required for read-only access
  69.  
  70. SWI MessageTrans_OpenFile
  71.    In   R0 -> 4-word data structure
  72.               must be held in the RMA if R2=0 on entry
  73.         R1 -> filename, held in the RMA if R2=0 on entry   
  74.                         (NOTE: FILENAME MUST REMAIN UNCHANGED FOR THE DURATION OG THE FILE BEING OPEN)
  75.         R2 -> buffer to hold file data
  76.               0 => allocate some space in the RMA,
  77.                    or use the file directly if possible
  78.         Error: "Message file already open" if R0 points to a structure
  79.                already known to MessageTrans (ie. already open).
  80.  
  81.         An application may decide that it would like to buffer the file in
  82.         its own workspace (rather than the RMA) if it needs to be loaded, or
  83.         use the file directly if it is already in memory.  To do this:
  84.  
  85.             SYS "MessageTrans_FileInfo",,filename$ TO flags%,,size%
  86.             IF flags% AND 1 THEN buffer%=0 ELSE buffer%=FNalloc(size%)
  87.             SYS "OS_Module",6,,,17+LENfilename$ TO ,,filedesc%
  88.             $(filedesc%+16)=filename$
  89.             SYS "MessageTrans_OpenFile",filedesc%,filedesc%+16,buffer%
  90.  
  91.         where FNalloc() allocates a buffer of a given size, by using the
  92.         Wimp_SlotSize or "END=" command.  Note that in fact the filename and
  93.         file descriptor only need to be in the RMA if R2=0 on entry to
  94.         MessageTrans_OpenFile.
  95.  
  96.   Note: If R2=0 on entry to this SWI, and the application uses direct
  97.         pointers into the file (rather than copying the messages out) or
  98.         uses MessageTrans_MakeMenus, it should also trap
  99.         Service_MessageFileClosed, in case the file is unloaded.
  100.  
  101. SWI MessageTrans_Lookup
  102.    In   R0 -> 4-word data structure passed to MessageTrans_OpenFile
  103.         R1 -> token, terminated by any char <= 32, or "," or ")"
  104.               or token:default message terminated by 0 char.
  105.         R2 -> buffer to hold result (0 => don't copy it)
  106.         R3 = buffer size (if R2 non-0)
  107.         R4 -> parameter 0 (0 => don't substitute for "%0")
  108.         R5 -> parameter 1 (0 => don't substitute for "%1")
  109.         R6 -> parameter 2 (0 => don't substitute for "%2")
  110.         R7 -> parameter 3 (0 => don't substitute for "%3")
  111.    Out  R1 -> terminator of token
  112.         R2 -> result string (read-only with no sustitution if R2=0 on entry)
  113.         R3 = size of result before terminator
  114.              (terminator = 10 if R2=0 on entry, else 0)
  115.  
  116.    This SWI allows a message token to be translated into a string, with
  117.    optional parameter substitution.
  118.  
  119.    The application must have called MessageTrans_OpenFile beforehand in
  120.    order to use this SWI, although you can still call it if the file has
  121.    been automatically closed by the system, because it will automatically
  122.    re-open it as well.
  123.  
  124.    If the message token does not match, the error "Message token not found"
  125.    is returned unless the token was followed by ":default value", in which
  126.    case the default value is returned (I.E. either copied to the buffer or
  127.    pointed at).  This error is also given if the value to be returned is on
  128.    the last line of the file, and does not have a terminating CHR$(10).
  129.  
  130.  
  131.    See the "File format" section for further details.
  132.  
  133.  
  134.  
  135. SWI MessageTrans_MakeMenus
  136.    In   R0 -> 4-word data structure passed to MessageTrans_OpenFile
  137.         R1 -> menu definition (see below)
  138.         R2 -> RAM buffer to hold menu structure
  139.         R3 = size of RAM buffer
  140.    Out  [R1..] = menu data
  141.         R3 = bytes remaining in buffer (should be 0 if you got it right)
  142.         "Buffer overflow" error if buffer is too small
  143.  
  144.    Menu structure:
  145.         +0 (n)  Token for menu title, terminated by any char <= 32, or "," or ")"
  146.                 null => no more menus, otherwise:
  147.         +n (1)  menu title foreground and frame colour
  148.            (1)  menu title background colour
  149.            (1)  menu work area foreground colour
  150.            (1)  menu work area background colour
  151.            (1)  height of menu items
  152.            (1)  gap between items
  153.         Menu items:
  154.            (n)  Token for menu item, terminated by any char <= 32, or "," or ")"
  155.            Word-align to here (addr := (addr+3) AND (NOT 3))
  156.            (4)  Menu flags (bit 7 set => last item)
  157.            (4)  Offset from RAM menu start to RAM submenu start
  158.                 0 => no submenu
  159.            (4)  Icon flags
  160.  
  161.    This SWI allows a menu structure to be set up from a structure
  162.    containing references to tokens, and sets up menu widths.  Parameter
  163.    substitution is not allowed.
  164.  
  165.    The application must have called MessageTrans_OpenFile beforehand in
  166.    order to use this SWI, although you can still call it if the file has
  167.    been automatically closed by the system, because it will automatically
  168.    re-open it as well.
  169.  
  170.    If the icon flags have bit 8 clear (ie. they are not indirected), the
  171.    message text for the icon will be read into the 12-byte block that forms
  172.    the icon data, otherwise the icon data will be set up to point to the
  173.    message text inside the file data.  In the latter case they are
  174.    read-only.
  175.  
  176.    If the menu item flags bit 2 is set (writeable) and the icon is
  177.    indirected, the 3 words of the icondata in the RAM buffer are assumed to
  178.    have already been set up by the calling program.  The result of looking
  179.    up the message token is copied into the buffer indicated by the first
  180.    word of the icon data (truncated if it gets bigger than the buffer size
  181.    indicated in [icondata,#8]).
  182.  
  183.  
  184. SWI MessageTrans_CloseFile
  185.    In   R0 -> 4-word data structure passed to MessageTrans_OpenFile
  186.  
  187.  
  188. Service_MessageFileClosed
  189.    In   R0 -> 4-word data structure passed to MessageTrans_OpenFile
  190.    Out  If the application recognises the value of R0 passed in, and it has
  191.         any direct pointers into the message data that it relates to, it
  192.         should re-initialise itself by calling MessageTrans_OpenFile again
  193.         to re-open the file, and recache its pointers.  If it has used
  194.         MessageTrans_MakeMenus, it should call Wimp_GetMenuState to see if
  195.         its menu tree it open, and delete it using Wimp_CreateMenu(-1) if
  196.         so.
  197.  
  198.    This service call is only ever issued if the file is not held in the
  199.    user's own buffer.  It tells the application that its file data has been
  200.    thrown away, for example if the file is held inside a module which is
  201.    then reloaded.
  202.  
  203.    It is only necessary to trap this service call if direct pointers into
  204.    the file data are being used.  Otherwise, the MessageTrans module will
  205.    make a note in the file descriptor that the file has been closed, and
  206.    simply re-open it when MessageTrans_Lookup or MessageTrans_MakeMenus is
  207.    next called on that file.
  208.  
  209.    It is recommended that applications that cannot trap service calls do not
  210.    use direct pointers into the file data (eg. indirected icons with
  211.    MessageTrans_MakeMenus).  They can still use such indirected icons, if
  212.    they provide a buffer pointer in R2 on entry to MessageTrans_OpenFile (so
  213.    that the message file data is copied into the buffer).
  214.  
  215.  
  216. Service_Reset
  217.  
  218.    Since MessageTrans does not close message files on a soft reset,
  219.    applications that do not wish their message files to be open once they
  220.    leave the desktop should call MessageTrans_CloseFile for all their open
  221.    files at this point.  However, it is perfectly legal for message files to
  222.    be left open over soft reset.
  223.  
  224.  
  225. File format
  226. -----------
  227.  
  228. Message files contain a series of one-line token / value pairs, terminated
  229. by character 10 (linefeed).
  230.  
  231.         <file> ::= { <line> }*
  232.         <line> ::= <tokline> | "#" <comment><nl> | <nl>
  233.      <tokline> ::= <token> { "/"<token> | <nl><token> }* : <value><nl>
  234.        <token> ::= <tokchar> { <tokchar> }*
  235.      <tokchar> ::= <char> | <wildcard>
  236.         <char> ::= any character > " " except ",", ")", ":", "?" or "/"
  237.     <wildcard> ::= "?"      (matches any character)
  238.      <comment> ::= { <anychar> }*
  239.      <anychar> ::= any character except <nl>
  240.           <nl> ::= character code 10
  241.        <value> ::= { <anychar> | "%0" | "%1" | "%2" | "%3" | "%%" }*
  242.  
  243. Note that the spaces in the above description are purely to improve
  244. readability - in fact spaces are significant inside tokens, so should only
  245. really appear in <comment> and <value>.
  246.  
  247. Alternative tokens are separated by "/" or <nl>.  If any of the alternative
  248. tokens before the next ":" match the supplied token, the value after the
  249. next ":" up to the following <nl> is returned.  The "?" character in a token
  250. in the file matches any character in the supplied match token.  Case is
  251. significant.
  252.  
  253. If R2 is not 0 on entry to MessageTrans_Lookup, "%0", "%1", "%2" and "%3"
  254. are subsitituted with the parameters supplied in R4..R7, except where the
  255. relevant register is 0, in which case the text is left alone.  "%%" is
  256. converted to "%" - otherwise if no parameter substitution occurs the text is
  257. left alone.  No other substitution is performed on the string.
  258.  
  259. For example:
  260.  
  261.         # This is an example message file
  262.  
  263.         TOK1:This value is obtained only for "TOK1".
  264.         TOK2
  265.         TOK3/TOK4:This value is obtained for "TOK2","TOK3" or "TOK4"
  266.         TOK?:This value is obtained for "TOK<not 1,2,3 or 4>"
  267.  
  268.         ANOTHER:Parameter in R4 = %0, parameter in R5 = %1.
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275. -----
  276. "We're children, Needing other children
  277.  And yet letting our grown up pride
  278.  Hide all the need inside
  279.  Acting more like children than children" 
  280. ---docs end---
  281.  
  282.    Thanks go to Ran Mokady for posting them in the first place...
  283.  
  284.     Philip
  285.  
  286. --
  287. Philip R. Banks                                                         @@@@@/|
  288. Syntax: mail <banks_p@kosmos.wcc.govt.nz|banksie@khantazi.welly.gen.nz> @@@@/#|
  289.                                                                         @@@/##|
  290. What price the crown of a king on his throne,                           @@/---|
  291. When you're chained in the dark all alone?  ---A.P.P.                   @/    |
  292.  
  293.  
  294.