home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 5 / FreshFish_July-August1994.bin / bbs / dev / flexcat-1.2.lha / FlexCat / doc / FlexCat_english.doc < prev    next >
Encoding:
Text File  |  1994-04-17  |  34.6 KB  |  822 lines

  1. FlexCat V1.2 Documentation
  2. **************************
  3.  
  4.    This file describes the Usage of FlexCat V1.2, a program which generates
  5. catalogs and the source to handle them. FlexCat works similar to
  6. CatComp and KitCat, but differs in generating any source you want.
  7. This is done by using the so called Source descriptions, which are a
  8. template for the code to generate. They can be edited and hence adapted to
  9. any programming language and individual needs. (Hopefully!)
  10.  
  11. Copyright and other legal stuff
  12. *******************************
  13.  
  14.      Copyright (C) 1993    Jochen Wiedmann
  15.                  Am Eisteich 9
  16.                72555 Metzingen (Deutschland)
  17.                  Tel. 07123 / 14881
  18.                  Internet: wiedmann@mailserv.zdv.uni-tuebingen.de
  19.  
  20.    Permission is granted to make and distribute verbatim and modified
  21. copies of this documentation and the program FlexCat following the terms of
  22. the "GNU General Public License" provided the copyright notice and this
  23. permission notice are preserved on all copies and the "GNU General Public
  24. License" (in the file COPYING) is distributed as well.
  25.  
  26.    The author gives absolutely no warranty that the program described in
  27. this documentation and the results produced by it are correct. The author
  28. cannot be held responsible for any damage  resulting from the use of this
  29. software.
  30.  
  31. Survey
  32. ******
  33.  
  34.    Since Workbench 2.1 the Amiga offers a rather pleasant system of using
  35. programs in different languages: The locale.library. (This is called
  36. localizing, that's what the name's for.)
  37.  
  38.    The idea is simple: You select a language, the english in most cases and
  39. write your program in the same manner as you did without localizing, except
  40. that constant strings are replaced by certain function calls. Another
  41. function call makes it possible that the user selects another language when
  42. the program starts. (The latter function call loads an external file, the
  43. so called catalog and makes the former to read the strings from the
  44. catalog instead of using the predefined strings.)
  45.  
  46.    These catalogs are independent from the program. All you need to do for
  47. adding another language is to create a new catalog file and this is
  48. possible at any time without changing the program.
  49.  
  50.    But there are additional tasks for the programmer: He needs to create the
  51. catalogs, the predefined strings and some source to handle them all. (The
  52. functions that are mentioned above.) FlexCat is designed to make this in an
  53. easy and nearly automatic manner without losing flexibility especially in
  54. creating the source. An example should make this clear:
  55.  
  56.    Lets assume that we want to write a HelloLocalWorld.c. Our final
  57. program will look like this:
  58.          #include <stdio.h>
  59.          #include <stdlib.h>
  60.          #include <HelloLocalWorld_Cat.h>    /*  You must include this! */
  61.          #include <clib/exec_protos.h>
  62.      
  63.          struct Library *LocaleBase;
  64.      
  65.          void main(int argc, char *argv[])
  66.          { /*  Open the library for yourself, even if the compiler supports  */
  67.            /*  automatic opening. NO exit, if OpenLibrary fails:    */
  68.            /*  We use the builtin strings in that case.            */
  69.            LocaleBase = OpenLibrary("locale.library", 38);
  70.      
  71.            OpenHelloLocalWorldCatalog(NULL, NULL);
  72.      
  73.            printf("%s\n", GetHelloLocalWorldString(msgHello));
  74.      
  75.            CloseHelloLocalWorldCatalog();
  76.            if (LocaleBase)
  77.            CloseLibrary(LocaleBase);
  78.          }
  79.  
  80. Note that this is quite the same as the original HelloWorld.c except for
  81. replacing the string "Hello, world!" by a function call and some minor
  82. initializing stuff.
  83.  
  84.    The above program uses a constant msgHello. A call to the functon
  85. GetHelloLocalWorldString replaces this by the respective string.
  86. These constants and strings are defined in a so called Catalog
  87. description file. (see Catalog description. You always start by creating
  88. such a file called HelloLocalWorld.cd, which could look like this:
  89.          ;    Comments ar eallowed, of course! Each line beginning with a
  90.          ;    semicolon is assumed to be a comment
  91.          ;
  92.          ;    The language of the builtin strings:
  93.          #language english
  94.          ;
  95.          ;    The catalog version, used for a call to Locale/OpenCatalog().
  96.          ;    This is different to Exec/OpenLibrary(): 0 means any catalog
  97.          ;    version, other numbers must match exactly!
  98.          #version 0
  99.          ;
  100.          ;    This defines a string and the ID which allows to use it.
  101.          ;    The number 4 says, that this string must not be shorter than
  102.          ;    4 characters.
  103.          msgHello (/4/)
  104.          Hello, world!
  105.  
  106.    By using FlexCat you create another two files from the catalog
  107. description: The include file HelloLocalWorld_Cat.h defines the constants
  108. and the HelloLocalWorld_Cat.c contains an array of strings and the
  109. functions OpenHelloLocalWorldCatalog()GetHelloLocalWorldString() and
  110. CloseHelloLocalWorldCatalog.  You don't need to know how they look, just
  111. use them. Especially you don't need to know anything about
  112. Locale.library!
  113.  
  114.    However, you might be interested, how these files look or even more, you
  115. might want them changed. This is the difference between FlexCat and other
  116. catalog generators: FlexCat is not forced to use a special builtin format
  117. for creating these files. Instead it uses external files, so called Source
  118. descriptions. This makes it possible, for example, to allow using catalogs
  119. with AmigaDOS 2.0. see Source description. If you use the source
  120. descriptions from the FlexCat distribution you can create the source files
  121. with the following commands:
  122.          FlexCat HelloLocalWorld.cd HelloLocalWorld_Cat.c=C_c_V21
  123.          FlexCat HelloLocalWorld.cd HelloLocalWorld_Cat.h=C_h.sd
  124.  
  125.    When your program is ready you use FlexCat again to create so called
  126. Catalog translation files, one for each language you would like to
  127. support. (Except english, which is builtin.) See Catalog translation.  Lets
  128. create a german catalog translation:
  129.          FlexCat HelloLocalWorld.cd NEWCTFILE Deutsch.ct
  130.  
  131. This file would no look as follows:
  132.          ## version
  133.          ## language
  134.          ## codeset 0
  135.          ;    Comments ar eallowed, of course! Each line beginning with a
  136.          ;    semicolon is assumed to be a comment
  137.          ;
  138.          ;    The language of the builtin strings:
  139.          ;
  140.          ;    The catalog version, used for a call to Locale/OpenCatalog().
  141.          ;    This is different to Exec/OpenLibrary(): 0 means any catalog
  142.          ;    version, other numbers must match exactly!
  143.          ;
  144.          ;    This defines a string and the ID which allows to use it.
  145.          ;    The number 4 says, that this string must not be shorter than
  146.          ;    4 characters.
  147.          msgHello
  148.      
  149.          ;Hello, world!
  150.  
  151. You see, it looks much like the catalog descriptions. FlexCat includes the
  152. comments from the catalog description, even where it is meaningless: Note
  153. the comment on the string length which shouldn't appear here as these
  154. informations must be in the catalog description only. All you have to do
  155. now is to fill in the informations on the version (a typical version string
  156. like $VER: Deutsch.catalog 1.0 (11.03.94) is expected), the language of
  157. the catalog translation (Deutsch for german here), the codeset (which
  158. should always be 0 for now, see Locale/OpenCatalog() for details) and of
  159. course the strings itself. FlexCat includes the original strings as
  160. comments, so you always know what to fill in.  Finally you create the
  161. catalogs with commands like
  162.          FlexCat HelloLocalWorld.cd Deutsch.ct CATALOG Deutsch.catalog
  163.  
  164. Note, that you don't need the program itself or the source files created
  165. with FlexCat for the catalogs! You can create new catalogs at any time.  It
  166. is usual to supply distributions with a file NewCatalog.ct, so users can
  167. create own catalogs.
  168.  
  169.    But what happens if you change the program later? Just edit the catalog
  170. description and use FlexCat to update the catalog translations:
  171.          FlexCat HelloLocalWorld.cd Deutsch.ct NEWCTFILE Deutsch.ct
  172.  
  173. All you need to do now is to enter new strings if needed.
  174.  
  175. Installation
  176. ************
  177.  
  178.    FlexCat is written in pure Ansi-C (except for the localization), hence it
  179. should run on any Amiga and hopefully on other machines after recompiling.
  180. (The localizing is commented out in that case.) This holds for the created
  181. programs too: FlexCat is written using itself. All distributed source
  182. descriptions should create programs running on any Amiga and even any
  183. machine. (Of course you must ensure that the variable LocaleBase has the
  184. value NULL in the latter case.) Localizing, however, is possible
  185. beginning with Workbench 2.1 because the locale.library isn't available
  186. below.
  187.  
  188.    It is not impossible to offer localizing without the locale.library:
  189. The source description files C_c_V20.sd and C_h_V20.sd give an example,
  190. where the iffparse.library is used to replace the locale.library, if it
  191. is not available. This gives Localizing for Workbench 2.0. See C.
  192.  
  193.    Installing FlexCat is simple: Just copy the program to a directory in
  194. your search path and select a place for the source descriptions you need.
  195. (These are the files called something like xx_yy.sd, where xx is the
  196. programming language.) If you want to use FlexCat in another language than
  197. the english you need to copy the respective catalog files too. E.g. for the
  198. german language copy the file Catalogs/Deutsch/FlexCat.catalog to
  199. Locale:Catalogs/Deutsch/FlexCat.catalog or to
  200. PROGDIR:Catalogs/Deutsch/FlexCat.catalog, where PROGDIR: is
  201. FlexCat's program directory. See Using FlexCat source.
  202.  
  203. Calling FlexCat from the CLI
  204. ****************************
  205.  
  206.    FlexCat is a CLI based program and doesn't operate from the workbench.
  207. It's calling syntax is
  208.          FlexCat CDFILE/a,CTFILE,CATALOG/k,NEWCTFILE/k,SOURCES/m
  209.  
  210. where the arguments mean
  211. CDFILE
  212.      is the name of a catalog description to be read. This is always needed.
  213.      Please note, that the base name of the source description is created
  214.      from it making this case significant. See Source description.
  215.  
  216. CTFILE
  217.      is the name of a catalog translation file to be read. This is needed
  218.      for creating catalogs or for updating an old catalog translation file
  219.      using the NEWCTFILE argument: FlexCat reads the old file and the
  220.      catalog description and creates a new catalog translation file
  221.      containing the old strings and possibly some empty lines for new
  222.      strings.
  223.  
  224. CATALOG
  225.      is the name of a catalog file to be created. This argument requires
  226.      giving CDFILE as well.
  227.  
  228. NEWCTFILE
  229.      is the name of a catalog translation file to create. FlexCat reads
  230.      strings from CTFILE, if this is given, strings missing in the catalog
  231.      translation are replaced by empty lines. (The new catalog translation
  232.      will contain only empty lines as strings, if CTFILE is omitted.)
  233.  
  234. SOURCES
  235.      are the names of source files to be created. These shoud be given in
  236.      the form source=template where source is the file to create and
  237.      template is the name of a source description file to be scanned.
  238.  
  239.    For examples of command lines see Survey.
  240.  
  241. Catalog description files
  242. *************************
  243.  
  244.    A catalog description file contains four kinds of lines.
  245.  
  246. Comment lines
  247.      Any line beginning with a semicolon is assumed to be a comment line,
  248.      hence ignored. (The string lines below are an exception. These may
  249.      begin with a semicolon.)
  250.  
  251. Command lines
  252.      Any line beginning with a '#' (with the same exception as above) are
  253.      assumed to be command lines. Possible commands are:
  254.     #language <str>
  255.           gives the programs default language, the language of the strings
  256.           in the catalog description. Default is #language english.
  257.  
  258.     #version <num>
  259.           gives the version number of catalogs to be opened. Note that this
  260.           number must match exact and not be same or higher as in
  261.           `Exec/OpenLibrary'.  An exception is the number 0, which accepts
  262.           any catalog. Default is #version 0. See Locale/OpenCatalog
  263.           for further information on catalog language and version.
  264.  
  265.     #lengthbytes <num>
  266.           Instructs FlexCat to put the given number of bytes before a
  267.           string containing its length. The length is the number of bytes
  268.           in the string without length bytes and a trailing NUL byte.
  269.           (Catalog files and hence catalog strings will have a trailing
  270.           NUL byte. This is not always true for the default strings,
  271.           depending on the source description file.) <num> must be
  272.           between 0 and sizeof(long)=4, Default is #lengthbytes 0.
  273.  
  274.     #basename <str>
  275.           Sets the basename of the source description. See Source
  276.           description.  This overwrites the basename from the command line
  277.           argument CDFILE.  See Program start.  Commands are case
  278.      insensitive.
  279.  
  280. Description lines
  281.      declare a string. They look like IDSTR (id/minlen/maxlen) where
  282.      IDSTR is a identifier (a string consisting of the characters
  283.      a-z,A-Z and 0-9), id is a unique number (from now on called ID),
  284.      minlen and maxlen are the strings minimum and maximum length,
  285.      respectively. The latter three may be missing (but not the characters
  286.      (//)!) in which case FlexCat chooses a number and makes no
  287.      restrictions on the string length.  Better don't use the ID's, if you
  288.      don't need. The lines following are the
  289.  
  290. String lines
  291.      containing the string itself and nothing else. These may contain
  292.      certain control characters beginning with a backslash:
  293.     \b
  294.           Backspace (Ascii 8)
  295.  
  296.     \c
  297.           Control Sequence Introducer (Ascii 155)
  298.  
  299.     \e
  300.           Escape (Ascii 27)
  301.  
  302.     \f
  303.           Form Feed (Ascii 12)
  304.  
  305.     \g
  306.           Display beep (Ascii 7)
  307.  
  308.     \n
  309.           Line Feed, newline (Ascii 10)
  310.  
  311.     \r
  312.           Carriage Return (Ascii 13)
  313.  
  314.     \t
  315.           Tab (Ascii 9)
  316.  
  317.     \v
  318.           Vertical tab (Ascii 11)
  319.  
  320.     \)
  321.           The trailing bracket which is possibly needed as part of a
  322.           (..) sequence, see Source description.
  323.  
  324.     \\
  325.           The backslash itself
  326.  
  327.     \xHH
  328.           The character given by the ascii code HH, where HH are hex
  329.           digits.
  330.  
  331.     \OOO
  332.           The character given by the ascii code OOO, where OOO are octal
  333.           digits.  Finally a single backslash at the end of the line causes
  334.      concatening the following line. This makes it possible to use strings
  335.      of any length, FlexCat makes no assumptions on string length.
  336.  
  337.    A string is hence given by a description line and the following string
  338. line.  Let's see an example:
  339.          msgHello (/4/)
  340.          Hello, this is english!\n
  341.  
  342. The ID is missing here, so FlexCat chooses a suitable number. The number 4
  343. instructs FlexCat, that the following string must not have less than four
  344. characters and it may be of any length. See the file FlexCat.cd for a
  345. further example.
  346.  
  347. Catalog translation files
  348. *************************
  349.  
  350.    Catalog translation files are very similar to catalog descriptions,
  351. except for other commands and having no informations on string ID and
  352. length.  (These are taken from the catalog description.) Any string from the
  353. catalog description must be present (However, FlexCat omits writing strings
  354. into the catalog which are identical to the default string.) and no
  355. additional identifiers may occur. This is easy assured by using FlexCat to
  356. create new catalog translation files. See Survey.
  357.  
  358.    The commands allowed in catalog translations are:
  359. ##version <str>
  360.      Gives the catalog version as AmigaDOS version string. Example:
  361.               ##version $VER: Deutsch.ct 8.1 (27.09.93)
  362.      The version number of this catalog is 8. Hence the catalog descriptions
  363.      version number must be 0 or 8.
  364.  
  365. ##language <str>
  366.      The catalogs language. Of course this should be another language than
  367.      the catalog descriptions language. The ##language and ##version
  368.      commands must be present in a catalog translation.
  369.  
  370. ##codeset <num>
  371.      Currently not used, must be 0. This is the default value.
  372.  
  373.    The string from above looks like this in the catalog translation:
  374.          msgHello
  375.          Hallo, dies ist deutsch!\n
  376.  
  377. See Deutsch.ct as further example of a catalog translation.
  378.  
  379. Source description files
  380. ************************
  381.  
  382.    This is the special part of FlexCat. Until now there is nothing that
  383. CatComp, KitCat and others don't offer too. The created source should make
  384. it easy, to use the catalogs without losing flexibility. Any programming
  385. language should be possible and any requirements should be satisfyable.
  386. This seems like a contradiction, but FlexCat's solution are the source
  387. description files containing a template of the source to be created. These
  388. are editable as the catalog description and translation files are, hence
  389. FlexCat can create any code.
  390.  
  391.    The source descriptions are searched for certain symbols which are
  392. replaced by certain values. Possible symbols are the backslash characters
  393. from above and additionally sequences beginning with a %. (This is well
  394. known for C programmers.)
  395. %b
  396.      is the base name of the catalog description. See Program start.
  397.  
  398. %v
  399.      is the version number of the catalog description. Don't mix this up
  400.      with the catalog version string from the catalog translation.
  401.  
  402. %l
  403.      is the catalog descriptions language. Please note, that this is
  404.      inserted as a string. See %s below.  below.
  405.  
  406. %n
  407.      is the number of strings in the catalog description.
  408.  
  409. %%
  410.      is the character % itself.
  411.  
  412.    But the most important thing are the following seqences. These represent
  413. the catalog strings in different ways. Lines containing one or more of these
  414. symbols are repeated for any String.
  415.  
  416. %i
  417.      is the identifier from the catalog description.
  418.  
  419. %d
  420.      is the strings ID.
  421.  
  422. %s
  423.      is the string itself; this will be inserted in a way depending on the
  424.      programming language and can be controlled using the commands
  425.      ##stringtype and ##shortstrings.
  426.  
  427. %(...)
  428.      inserts the text between the brackets for any string except the last.
  429.      This is probably needed in Arrays, if the array entries should be
  430.      separated by commas, but the last entry must not be followed by a
  431.      comma. You can use %(,) in that case. Note that within the brackets
  432.      there is no replacing of % sequences. Backslash sequences, however,
  433.      are still allowed.
  434.  
  435.    The control sequences %l and %s create strings. But how strings look
  436. depends on the program language. That's why the source description allows
  437. command lines similar to the catalog translation. These must begin with the
  438. first character of the line and any command must have its own line.
  439. Possible commands are:
  440. ##shortstrings
  441.      makes longer strings to be splitted on different lines. This is
  442.      probably not always possible or not implemented into FlexCat and hence
  443.      the default is to create one, probably very long string.
  444.  
  445. ##stringtype <type>
  446.      Tells FlexCat how strings should look like. Possible types are
  447.     None
  448.           No additional characters are created. An image of the string is
  449.           inserted and nothing else. No output of binary characters (the
  450.           backslash sequences) is possible.
  451.  
  452.     C
  453.           creates strings according to C. The strings are preceded and
  454.           followed by the character ". Strings are splitted using the
  455.           sequences "\ at the end of the line and " at the beginning of
  456.           the new line. (The backslash is needed in macros.) Binary
  457.           characters are inserted using \OOO. See C.
  458.  
  459.     Oberon
  460.           is like string type C, except for the trailing backslash at the
  461.           end of the line.
  462.  
  463.     Assembler
  464.           Strings are created using dc.b. Readable ascii characters are
  465.           preceded and followed by the character ', binary characters are
  466.           inserted as $XX. See Assembler.
  467.  
  468.     E
  469.           Strings are preceded and followed by the character '. A +
  470.           concatenates strings which are spread on different lines. Binary
  471.           characters are inserted like in C.
  472.  
  473.    Let's look at an excerpt from the file C_h.sd creating an include file
  474. for the programming language C.
  475.      ##stringtype C
  476.      ##shortstrings
  477.      
  478.      #ifndef %b_CAT_H    /*    Assure that this is read only once. */
  479.      #define %b_CAT_H
  480.      
  481.      
  482.      /*  Get other include files    */
  483.      #include <exec/types.h>
  484.      #include <libraries/locale.h>
  485.      
  486.      
  487.      /*  Prototypes    */
  488.      extern void Open%bCatalog(struct Locale *, STRPTR);
  489.      extern void Close%bCatalog(void);
  490.      extern STRPTR Get%bString(LONG);
  491.      
  492.      /*  Definitions of the identifiers and their ID's           */
  493.      /*  This line will be repeated for any string.            */
  494.      #define %i %d
  495.      
  496.      #endif
  497.  
  498. Including FlexCat source in own programs
  499. ****************************************
  500.  
  501.    Of course this depends on what source is created and hence on the source
  502. description. What we are talking here about are the source description
  503. files distributed with FlexCat. See Source description.
  504.  
  505.    All source descriptions should allow using the program without
  506. locale.library. However, a global variable called LocaleBase
  507. (_LocaleBase for assembler) must be present and initialized with NULL
  508. or by a call to `Exec/OpenLibrary'. No localizing is possible in the former
  509. case except when using the source description C_c_V20.sd.  This allows
  510. localizing on 2.0 by repacing the locale.library with the
  511. iffparse.library. (A variable IFFParseBase has to be present for
  512. this and initialized like LocaleBase.) See C.  The programmer does not
  513. need knowledge of these libraries except when creating own source
  514. descriptions.
  515.  
  516.    There are three functions and calling them is rather simple.
  517.  
  518.  - : OpenCatalog (locale, language)
  519.      This function possibly opens a catalog. The argument locale is a
  520.      pointer to a Locale structure amd language is a string containing
  521.      the name of the language that should be opened. In most cases these
  522.      should both be NULL or NIL, respectively, because the user's
  523.      defaults are overwritten otherwise. See `Locale.OpenCatalog' for
  524.      details.
  525.  
  526.      If the user has Deutsch and Français as default languages and the
  527.      programs base name is XXX this looks for the following files:
  528.               PROGDIR:Catalogs/Deutsch/XXX.catalog
  529.               LOCALE:Catalogs/Deutsch/XXX.catalog
  530.               PROGDIR:Catalogs/Français/XXX.catalog
  531.               LOCALE:Catalogs/Français/XXX.catalog
  532.  
  533.      where PROGDIR: is the programs current directory. (The order of
  534.      PROGDIR: and LOCALE: can get changed in order to suppress a
  535.      requester like Insert volume YYY.
  536.  
  537.      OpenCatalog is of type void (a procedure for Pascal programmers) and
  538.      hence gives no result.
  539.  
  540.  - : GetString (ID)
  541.      Gives a pointer to the string with the given ID from the catalog
  542.      description.  Of course these strings are owned by locale.library
  543.      and must not be modified.
  544.  
  545.      An example might be useful. Take the string from the catalog
  546.      description example, which was called msgHello. The source
  547.      descriptions declare a constant msgHello representing the ID. This
  548.      could be printed in C using
  549.               printf("%s\n", GetString(msgHello));
  550.  
  551.  - : CloseCatalog (void)
  552.      This function frees the catalog (that is the allocated RAM) before
  553.      terminating the program. You can call this function at any time even
  554.      before OpenCatalog is called.
  555.  
  556. FlexCat source in C programs
  557. ============================
  558.  
  559.    C source consists of two parts: A .c file which should be compiled and
  560. linked without further notice and an include file which should be included
  561. from any source part using catalog strings and which defines the ID's as
  562. macros.
  563.  
  564.    Two different versions are available for the .c part: C_c_V21.sd is
  565. a rather simple version using the respective functions of the
  566. locale.library and allowing localizing beginning with Workbench 2.1.
  567. But C_c_V20.sd replaces the locale.library with the
  568. iffparse.library if the former isn't available and the latter is.
  569. This allows localizing for Workbench 2.0 too. Programs using this should
  570. have an option Language and give the corresponding argument to
  571. OpenCatalog. This option should not be used in 2.1 and above and
  572. hence the language argument of OpenCatalog should still be NULL.
  573.  
  574.    Of course it would be possible to write a third version using catalogs
  575. with Ansii C, but I don't want to support 1.3 anymore.
  576.  
  577.    To separate the FlexCat functions OpenCatalog and CloseCatalog from
  578. the corresponding Locale functions with the same names and to allow
  579. different catalogs in one program the FlexCat functions get slightly
  580. modified names here: OpenXXXCatalogCloseXXXCatalog and
  581. GetXXXString, where XXX is the base name from the source
  582. description. The concept is copied from the GadToolsBox and prooved good,
  583. as I think. See Source description.
  584.  
  585.    The function prototypes are:
  586.          void OpenXXXCatalog(struct Locale *loc, char *language);
  587.          STRPTR GetXXXString(ULONG);
  588.          void CloseXXXCatalog(void);
  589.  
  590.    For an example see HelloLocalWorld.c. (see Survey)
  591.  
  592. FlexCat source in Oberon programs
  593. =================================
  594.  
  595.    There are two different source descriptions: Oberon_V38.sd creates
  596. source using Locale.mod from Hartmut Goebel. Oberon_V39.sd creates
  597. source using the Locale.mod distributed with AmigaOberon.
  598.  
  599.    The function prototypes are
  600.          XXX.OpenCatalog(loc: Locale.LocalePtr; language : ARRAY OF CHAR);
  601.          XXX.GetString(num: LONGINT): Exec.StrPtr;
  602.          XXX.CloseCatalog();
  603.  
  604. where XXX is the basename from the source description.  See Source
  605. description.
  606.  
  607.    Finally an example using FlexCat source:
  608.          MODULE HelloLocalWorld;
  609.      
  610.          IMPORT  x:=HelloLocalWorld_Cat; Dos;
  611.      
  612.          BEGIN
  613.            x.OpenCatalog(NIL, "");
  614.      
  615.            Dos.PrintF("%s\n", x.GetString(x.msgHello));
  616.      
  617.            (* Catalog will be closed automatically       *)
  618.            (* when program exits.                        *)
  619.          END Anything;
  620.  
  621. FlexCat source in Assembler programs
  622. ====================================
  623.  
  624.    Assembler source is created for usage with the Aztec Assembler.  This
  625. should not be very different to other assemblers and you should be able to
  626. implement own source descriptions. The source consists of two parts: A
  627. .asm file which should be assembled and linked without further notice
  628. and an .i include file which defines the string ID's and must be included
  629. by the using program.
  630.  
  631.    The FlexCat-function names are slightly modified to allow the usage of
  632. different catalogs in one file: These are OpenXXXCatalog,
  633. CloseXXXCatalog and GetXXXString, where XXX is the base name from
  634. the source description. The concept is copied from the GadToolsBox and
  635. prooved good, as I think. See Source description.
  636.  
  637.    As usual the function result is given in d0 and the functions save
  638. registers d2-d7 and a2-a7. OpenCatalog expects its arguments in a0 (pointer
  639. to Locale structure) and a1 (Pointer to language string) which should be
  640. NULL in most cases. GetString expects an string ID in d0.
  641.  
  642.    Finally an example of a program using FLexCat source:
  643.      *   HelloLocalWorld.asm
  644.          include "XXX.i" ; Opening this is a must. This
  645.                  ; contains "xref OpenHelloLocalWorldCatalog", ...
  646.      
  647.          xref    _LVOOpenLibrary
  648.          xref    _LVOCloseLibrary
  649.          xref    _AbsExecBase
  650.      
  651.          dseg
  652.      LocNam: dc.b    "locale.library",0
  653.          dc.l    _LocaleBase,4        ; Must be present under this name
  654.      
  655.          cseg
  656.      
  657.      main:    move.l    #38,d0            ; Open locale.library
  658.          lea    LocName,a1
  659.          move.l    _AbsExecBase.a6
  660.          jsr    _LVOOpenLibrary(a6)
  661.      *   NO exit, if OpenLibrary fails
  662.      
  663.          sub.l    a0,a0            ; Open catalog
  664.          sub.l    a1,a1
  665.          jsr    OpenHelloLocalWorldCatalog
  666.      
  667.          move.l    #msgHello,d0        ; Get pointer to string
  668.          jsr    GetHelloLocalWorldString
  669.          jsr    PrintD0         ; and print it
  670.      
  671.      Ende:
  672.          jsr    CloseHelloLocalWorldCatalog ; Close Catalog
  673.          move.l    _LocaleBase,a1        ; Close locale.library
  674.          move.l    a1,d0            ; this test is a must for 1.3
  675.          beq    Ende1
  676.          jsr    CloseLibrary
  677.      Ende1:
  678.          rts
  679.          end
  680.  
  681. FlexCat source in E programs
  682. ============================
  683.  
  684.    E differs from drastically other programming languages in one certain
  685. point: You cannot compile separate modules and link them together. All
  686. source must be in one file. The best solution for this problem is to use
  687. EPP from Barry Wills. (Sources: Aminet, directory dev/e, Fish disks) This
  688. allows you to integrate the sources created with the source description
  689. E21b.sd with one line:
  690.          PMODULE 'xxx_cat'
  691.  
  692. where xxx is the basename of your application. Without EPP you need to
  693. insert the FlexCat-source manually into your own source. You must insert
  694. the source between after your own definitions and before the first
  695. procedure. (Otherwise you would be forced to create and insert more than
  696. one file with FlexCat-source.)
  697.  
  698.    The created source contains functions get_xxx_string,
  699. open_xxx_catalog and close_xxx_catalog. (These slightly modified
  700. names are needed to allow different catalogs in one program.) Please note
  701. that (unlike in C, for example) you must not call get_xxx_string before
  702. open_xxx_catalog!
  703.  
  704.    A HelloLocalWorld.e using EPP might look like this:
  705.          /*    HelloLocalWorld.e   */
  706.      
  707.          PMODULE hellolocalworld_cat
  708.      
  709.          PROC main()
  710.          /*  Open Locale.library; No exit, if failure!        */
  711.          localebase := OpenLibrary('locale.library', 0)
  712.      
  713.          /*  Open the catalog file.                    */
  714.          open_hellolocalworld_catalog(NIL, NIL)
  715.      
  716.          WriteF('\s\n', get_hellolocalworld_string(MSG_HELLO_WORLD))
  717.      
  718.          close_hellolocalworld_catalog()
  719.          ENDPROC
  720.  
  721. Further development of FlexCat
  722. ******************************
  723.  
  724.    I don't expect much further development for I think FlexCat to be rather
  725. complete. Of course I'm open for suggestions, tips or critics. Especially I
  726. offer to include new string types because this is possible with very minor
  727. changes.
  728.  
  729.    I would be pleased, if someone would send me new source descriptions and
  730. I could introduce them into further distributions. Any programming language,
  731. any extensions, provided that they are prooved good by testing the source in
  732. a real existing program. And I would appreciate receiving new catalogs.  It
  733. is enough to insert the strings in the file NewCatalogs.ct which is part
  734. of the distribution.
  735.  
  736. Credits
  737. *******
  738.  
  739.    My thanks go to:
  740. Albert Weinert
  741.      for KitCat, the predecessor of FlexCat which has done me valuable
  742.      things, but finally wasn't flexible enough.
  743.  
  744. Reinhard Spisser und Sebastiano Vigna
  745.      for the Amiga version of texinfo. This documentation is written using
  746.      it.
  747.  
  748. The Free Software Foundation
  749.      for the original version of texinfo and many other excellent software.
  750.  
  751. Matt Dillon
  752.      for DICE and especially for DME.
  753.  
  754. Alessandro Galassi
  755.      for the italian catalog.
  756.  
  757. Lionel Vintenat
  758.      for the E source description and its documentation, the french catalogs
  759.      and bug reports.
  760.  
  761. The people of #AmigaGer
  762.      for answering many stupid questions and lots of fun, for example
  763.      stefanb (Stefan Becker), PowerStat (Kai Hoffmann), \ ill (Markus
  764.      Illenseer), Quarvon (Jürgen Lang), ZZA (Bernhard Möllemann), Tron
  765.      (Mathias Scheler), mungo (Ignatios Souvlatzis), \ jow (Jürgen
  766.      Weinelt) und Stargazer (Petra Zeidler).
  767.  
  768. Commodore
  769.      for the Amiga and Kickstart 2.0. Keep on developing it and I'll be an
  770.      Amiga-user for the next 8 years too. ;-)
  771.  
  772. Index
  773. *****
  774.  
  775.  
  776.  
  777.  .cd                                    Catalog description
  778.  .ct                                    Catalog translation
  779.  .sd                                    Source description
  780.  Adress                                 Disclaimer
  781.  Ascii-Code                             Catalog description
  782.  Assembler                              Assembler
  783.  Author                                 Disclaimer
  784.  AztecAs_asm.sd                         Assembler
  785.  AztecAs_i.sd                           Assembler
  786.  C                                      C
  787.  Catalog description                    Catalog description
  788.  Catalog translation                    Catalog translation
  789.  CLI                                    Program start
  790.  Contributions                          Future
  791.  Control characters                     Catalog description
  792.  Copyright                              Disclaimer
  793.  Credits                                Credits
  794.  C_c_V20.sd                             C
  795.  C_c_V21.sd                             C
  796.  C_h.sd                                 C
  797.  Deutsch.ct                             Catalog translation
  798.  Distribution                           Disclaimer
  799.  E                                      E
  800.  E21b.sd                                E
  801.  E21b_defs.sd                           E
  802.  E21b_procs.sd                          E
  803.  EPP                                    E
  804.  FlexCat                                Future
  805.  FlexCat source                         Using FlexCat source
  806.  FlexCat.cd                             Catalog description
  807.  Future                                 Future
  808.  Installation                           Installation
  809.  Internet                               Disclaimer
  810.  Mail                                   Disclaimer
  811.  Oberon                                 Oberon
  812.  Oberon_V38.sd                          Oberon
  813.  Oberon_V39.sd                          Oberon
  814.  Permissions                            Disclaimer
  815.  Prohibitions                           Disclaimer
  816.  Requirements                           Installation
  817.  Source description                     Source description
  818.  Survey                                 Survey
  819.  Using FlexCat source                   Using FlexCat source
  820.  Workbench                              Program start
  821.  
  822.