home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / documentation / documents / a252msgt < prev    next >
Internet Message Format  |  1999-04-27  |  10KB

  1. From: RMokady@acorn.co.uk (Ran Mokady)
  2. Subject: Re: MessageTrans
  3. Date: 13 Mar 91 16:31:35 GMT
  4.  
  5. As requested here is the MessageTrans documentation. 
  6.  
  7. Overview
  8. --------
  9.  
  10. This document describes the SWI interface to the MessageTrans module, which
  11. provides message translation services, and the format of the message files
  12. that it uses.
  13.  
  14.  
  15. SWI MessageTrans_FileInfo
  16.    In   R1 -> filename
  17.    Out  R0 = flag word:
  18.              bit 0 set => file is held in memory (can be accessed directly)
  19.              bits 1..31 reserved (ignore them)
  20.         R2 = size of buffer required to hold file
  21.              if R0 bit 0 set, the buffer is not required for read-only access
  22.  
  23. SWI MessageTrans_OpenFile
  24.    In   R0 -> 4-word data structure
  25.               must be held in the RMA if R2=0 on entry
  26.         R1 -> filename, held in the RMA if R2=0 on entry   
  27.                         (NOTE: FILENAME MUST REMAIN UNCHANGED FOR THE DURATION OG THE FILE BEING OPEN)
  28.         R2 -> buffer to hold file data
  29.               0 => allocate some space in the RMA,
  30.                    or use the file directly if possible
  31.         Error: "Message file already open" if R0 points to a structure
  32.                already known to MessageTrans (ie. already open).
  33.  
  34.         An application may decide that it would like to buffer the file in
  35.         its own workspace (rather than the RMA) if it needs to be loaded, or
  36.         use the file directly if it is already in memory.  To do this:
  37.  
  38.             SYS "MessageTrans_FileInfo",,filename$ TO flags%,,size%
  39.             IF flags% AND 1 THEN buffer%=0 ELSE buffer%=FNalloc(size%)
  40.             SYS "OS_Module",6,,,17+LENfilename$ TO ,,filedesc%
  41.             $(filedesc%+16)=filename$
  42.             SYS "MessageTrans_OpenFile",filedesc%,filedesc%+16,buffer%
  43.  
  44.         where FNalloc() allocates a buffer of a given size, by using the
  45.         Wimp_SlotSize or "END=" command.  Note that in fact the filename and
  46.         file descriptor only need to be in the RMA if R2=0 on entry to
  47.         MessageTrans_OpenFile.
  48.  
  49.   Note: If R2=0 on entry to this SWI, and the application uses direct
  50.         pointers into the file (rather than copying the messages out) or
  51.         uses MessageTrans_MakeMenus, it should also trap
  52.         Service_MessageFileClosed, in case the file is unloaded.
  53.  
  54. SWI MessageTrans_Lookup
  55.    In   R0 -> 4-word data structure passed to MessageTrans_OpenFile
  56.         R1 -> token, terminated by any char <= 32, or "," or ")"
  57.               or token:default message terminated by 0 char.
  58.         R2 -> buffer to hold result (0 => don't copy it)
  59.         R3 = buffer size (if R2 non-0)
  60.         R4 -> parameter 0 (0 => don't substitute for "%0")
  61.         R5 -> parameter 1 (0 => don't substitute for "%1")
  62.         R6 -> parameter 2 (0 => don't substitute for "%2")
  63.         R7 -> parameter 3 (0 => don't substitute for "%3")
  64.    Out  R1 -> terminator of token
  65.         R2 -> result string (read-only with no sustitution if R2=0 on entry)
  66.         R3 = size of result before terminator
  67.              (terminator = 10 if R2=0 on entry, else 0)
  68.  
  69.    This SWI allows a message token to be translated into a string, with
  70.    optional parameter substitution.
  71.  
  72.    The application must have called MessageTrans_OpenFile beforehand in
  73.    order to use this SWI, although you can still call it if the file has
  74.    been automatically closed by the system, because it will automatically
  75.    re-open it as well.
  76.  
  77.    If the message token does not match, the error "Message token not found"
  78.    is returned unless the token was followed by ":default value", in which
  79.    case the default value is returned (I.E. either copied to the buffer or
  80.    pointed at).  This error is also given if the value to be returned is on
  81.    the last line of the file, and does not have a terminating CHR$(10).
  82.  
  83.  
  84.    See the "File format" section for further details.
  85.  
  86.  
  87.  
  88. SWI MessageTrans_MakeMenus
  89.    In   R0 -> 4-word data structure passed to MessageTrans_OpenFile
  90.         R1 -> menu definition (see below)
  91.         R2 -> RAM buffer to hold menu structure
  92.         R3 = size of RAM buffer
  93.    Out  [R1..] = menu data
  94.         R3 = bytes remaining in buffer (should be 0 if you got it right)
  95.         "Buffer overflow" error if buffer is too small
  96.  
  97.    Menu structure:
  98.         +0 (n)  Token for menu title, terminated by any char <= 32, or "," or ")"
  99.                 null => no more menus, otherwise:
  100.         +n (1)  menu title foreground and frame colour
  101.            (1)  menu title background colour
  102.            (1)  menu work area foreground colour
  103.            (1)  menu work area background colour
  104.            (1)  height of menu items
  105.            (1)  gap between items
  106.         Menu items:
  107.            (n)  Token for menu item, terminated by any char <= 32, or "," or ")"
  108.            Word-align to here (addr := (addr+3) AND (NOT 3))
  109.            (4)  Menu flags (bit 7 set => last item)
  110.            (4)  Offset from RAM menu start to RAM submenu start
  111.                 0 => no submenu
  112.            (4)  Icon flags
  113.  
  114.    This SWI allows a menu structure to be set up from a structure
  115.    containing references to tokens, and sets up menu widths.  Parameter
  116.    substitution is not allowed.
  117.  
  118.    The application must have called MessageTrans_OpenFile beforehand in
  119.    order to use this SWI, although you can still call it if the file has
  120.    been automatically closed by the system, because it will automatically
  121.    re-open it as well.
  122.  
  123.    If the icon flags have bit 8 clear (ie. they are not indirected), the
  124.    message text for the icon will be read into the 12-byte block that forms
  125.    the icon data, otherwise the icon data will be set up to point to the
  126.    message text inside the file data.  In the latter case they are
  127.    read-only.
  128.  
  129.    If the menu item flags bit 2 is set (writeable) and the icon is
  130.    indirected, the 3 words of the icondata in the RAM buffer are assumed to
  131.    have already been set up by the calling program.  The result of looking
  132.    up the message token is copied into the buffer indicated by the first
  133.    word of the icon data (truncated if it gets bigger than the buffer size
  134.    indicated in [icondata,#8]).
  135.  
  136.  
  137. SWI MessageTrans_CloseFile
  138.    In   R0 -> 4-word data structure passed to MessageTrans_OpenFile
  139.  
  140.  
  141. Service_MessageFileClosed
  142.    In   R0 -> 4-word data structure passed to MessageTrans_OpenFile
  143.    Out  If the application recognises the value of R0 passed in, and it has
  144.         any direct pointers into the message data that it relates to, it
  145.         should re-initialise itself by calling MessageTrans_OpenFile again
  146.         to re-open the file, and recache its pointers.  If it has used
  147.         MessageTrans_MakeMenus, it should call Wimp_GetMenuState to see if
  148.         its menu tree it open, and delete it using Wimp_CreateMenu(-1) if
  149.         so.
  150.  
  151.    This service call is only ever issued if the file is not held in the
  152.    user's own buffer.  It tells the application that its file data has been
  153.    thrown away, for example if the file is held inside a module which is
  154.    then reloaded.
  155.  
  156.    It is only necessary to trap this service call if direct pointers into
  157.    the file data are being used.  Otherwise, the MessageTrans module will
  158.    make a note in the file descriptor that the file has been closed, and
  159.    simply re-open it when MessageTrans_Lookup or MessageTrans_MakeMenus is
  160.    next called on that file.
  161.  
  162.    It is recommended that applications that cannot trap service calls do not
  163.    use direct pointers into the file data (eg. indirected icons with
  164.    MessageTrans_MakeMenus).  They can still use such indirected icons, if
  165.    they provide a buffer pointer in R2 on entry to MessageTrans_OpenFile (so
  166.    that the message file data is copied into the buffer).
  167.  
  168.  
  169. Service_Reset
  170.  
  171.    Since MessageTrans does not close message files on a soft reset,
  172.    applications that do not wish their message files to be open once they
  173.    leave the desktop should call MessageTrans_CloseFile for all their open
  174.    files at this point.  However, it is perfectly legal for message files to
  175.    be left open over soft reset.
  176.  
  177.  
  178. File format
  179. -----------
  180.  
  181. Message files contain a series of one-line token / value pairs, terminated
  182. by character 10 (linefeed).
  183.  
  184.         <file> ::= { <line> }*
  185.         <line> ::= <tokline> | "#" <comment><nl> | <nl>
  186.      <tokline> ::= <token> { "/"<token> | <nl><token> }* : <value><nl>
  187.        <token> ::= <tokchar> { <tokchar> }*
  188.      <tokchar> ::= <char> | <wildcard>
  189.         <char> ::= any character > " " except ",", ")", ":", "?" or "/"
  190.     <wildcard> ::= "?"      (matches any character)
  191.      <comment> ::= { <anychar> }*
  192.      <anychar> ::= any character except <nl>
  193.           <nl> ::= character code 10
  194.        <value> ::= { <anychar> | "%0" | "%1" | "%2" | "%3" | "%%" }*
  195.  
  196. Note that the spaces in the above description are purely to improve
  197. readability - in fact spaces are significant inside tokens, so should only
  198. really appear in <comment> and <value>.
  199.  
  200. Alternative tokens are separated by "/" or <nl>.  If any of the alternative
  201. tokens before the next ":" match the supplied token, the value after the
  202. next ":" up to the following <nl> is returned.  The "?" character in a token
  203. in the file matches any character in the supplied match token.  Case is
  204. significant.
  205.  
  206. If R2 is not 0 on entry to MessageTrans_Lookup, "%0", "%1", "%2" and "%3"
  207. are subsitituted with the parameters supplied in R4..R7, except where the
  208. relevant register is 0, in which case the text is left alone.  "%%" is
  209. converted to "%" - otherwise if no parameter substitution occurs the text is
  210. left alone.  No other substitution is performed on the string.
  211.  
  212. For example:
  213.  
  214.         # This is an example message file
  215.  
  216.         TOK1:This value is obtained only for "TOK1".
  217.         TOK2
  218.         TOK3/TOK4:This value is obtained for "TOK2","TOK3" or "TOK4"
  219.         TOK?:This value is obtained for "TOK<not 1,2,3 or 4>"
  220.  
  221.         ANOTHER:Parameter in R4 = %0, parameter in R5 = %1.
  222.  
  223.