Bringing flexcat 2.15 into the main branch
[AROS.git] / tools / flexcat / doc / FlexCat_english.texinfo
blob1ffc5503c5bcf485751adee88f73673b712fcad9
1 \input amigatexinfo
2 \input texinfo
4 @c
5 @c $Id: FlexCat_english.texinfo 73 2007-01-01 02:48:17Z tactica $
6 @c
8 @c **** TODO ****
9 @c
10 @c - Fix FIXMEs.
11 @c - Complete the index
12 @c - Check all styles for consistency. Can't avoid the feeling that they
13 @c   are all mixed up at the moment...
14 @c 
15 @c -------------------------------------------------------------------------
17 @c %**start of header
18 @setfilename FlexCat_english
19 @settitle Documentation for FlexCat 2.6.7
20 @setchapternewpage off
21 @iftex
22 @parskip=0.75em
23 @end iftex
24 @c %**end of header
26 @titlepage
27 @title{FlexCat}
28 @subtitle{The flexible catalog generator}
29 @subtitle{}
30 @subtitle{Version 2.6.7}
31 @author Jochen Wiedmann and Marcin Orlowski
32 @vskip 0pt plus 1filll
33 @tex
34 @halign{@hfil#&#@hfil@cr
35        As of 2.6.3, FlexCat is developed by:@cr
36 @cr
37        & Ondrej Zima@cr
38        & amiandrew@@volny.cz@cr
39 @ct
40        Releases 2.5 - 2.6.2 were developed by:@cr
41 @cr
42        & Stefan Kost@cr
43        & ensonic@@sonicpulse.de@cr
44 @cr
45        Releases 1.8 - 2.4 were developed by:@cr
46 @cr
47        & Marcin Orlowski@cr
48        & ul. Radomska 38@cr
49        & 71-002 Szczecin@cr
50        & Poland@cr
51 @cr
52        & carlos@@amiga.com.pl@cr
53 @cr
54        Originally created by:@cr
55 @cr
56        & Jochen Wiedmann@cr
57        & Am Eisteich 9@cr
58        & 72555 Metzingen@cr
59        % Deutschland
61 @end tex
63 Permission is granted to make and distribute verbatim copies of this manual
64 and the program FlexCat.
66 @ignore
67 Permission is granted to process this file by TeX and print the results,
68 provided the printed document carries a copying permission notice identical to
69 this one except for the removal of this paragraph (this paragraph not being
70 relevant to the printed manual).
71 @end ignore
73 The author gives @strong{absolutely no} warranty that the program described
74 in this documentation and the results produced by it are correct. The
75 author cannot be held responsible for @strong{any} damage resulting from
76 the use of this software.
77 @end titlepage
79 @iftex
80 @headings double
81 @end iftex
83 @ifinfo
84 @c -------------------------------------------------------------------------
85 @node Top
86 @top Documentation for FlexCat 2.6.7
87 This file describes the usage of FlexCat 2.6.7, a program that generates
88 catalogs and the source to handle them. FlexCat works in a similar fashion
89 to @code{CatComp} and @code{KitCat}, but differs in that it generates any
90 sources you want. This is done by using the so called @dfn{Source descriptions},
91 a set of templates that tell how the code is to be generated. They can be
92 edited and hence adapted to any programming language and individual needs
93 (hopefully!).
95 @menu
96 General
98 * Disclaimer::            Copyrights, (NO) warranty
99 * Overview::              What is FlexCat?
100 * Installation::          How can I get it working?
102 Using FlexCat
104 * Program start::         Calling FlexCat from the CLI
105 * Preferences::           Changing the default behaviour
106 * Catalog description::   Catalog description files (@key{.cd} files)
107 * Catalog translation::   Catalog translation files (@key{.ct} files)
108 * Source description::    Source description (@key{.sd} files)
109 * Using FlexCat source::  Using FlexCat source in your own programs
111 Other
113 * Future::                The future of FlexCat
114 * Support::               Where to look for updates
115 * History::               History of development
116 * Credits::               What I always wanted to say@dots{}
117 * Index::                 Where can you find what you are looking for
119 @end menu
120 @end ifinfo
122 @ifinfo
123 @c -------------------------------------------------------------------------
124 @node Disclaimer
125 @chapter Copyright and other legal stuff
126 @cindex Copyright
127 @cindex Distribution
128 @cindex Permissions
129 @cindex Prohibitions
130 @cindex Author
131 @cindex Adress
132 @cindex Internet
133 @cindex Mail
134 FlexCat is Copyright @copyright{} 1993-1999 Jochen Wiedmann and Marcin Orlowski
136 @example
137             Jochen Wiedmann
138             Am Eisteich 9
139             72555 Metzingen
140             Germany
143             Releases 1.8 - 2.4 were developed by
145             Marcin Orlowski
146             ul. Radomska 38
147             71-002 Szczecin
148             Poland
150             carlos@@amiga.com.pl
153             Releases 2.5 - 2.6.2 were developed by
155             Stefan Kost
156             ensonic@@sonicpulse.de
159             As of 2.6.3, FlexCat is maintained by
161             Ondrew Zima
162             amiandrew@@volny.cz
164 @end example
166 Permission is granted to make and distribute verbatim copies of this manual
167 and the program FlexCat.
169 @ignore
170 Permission is granted to process this file by TeX and print the results,
171 provided the printed document carries a copying permission notice identical to
172 this one except for the removal of this paragraph (this paragraph not being
173 relevant to the printed manual).
174 @end ignore
176 The author gives @strong{absolutely no} warranty that the program described
177 in this documentation and the results produced by it are correct. The
178 author cannot be held responsible for @strong{any} damage resulting from
179 the use of this software.
180 @end ifinfo
183 @iftex
184 @vfill@eject
185 @end iftex
187 @c -------------------------------------------------------------------------
189 @node Overview
190 @chapter Overview
191 @cindex Overview
192 Since Workbench 2.1, AmigaOS offers a rather pleasant system for using
193 programs in different languages: @code{locale.library}. This library made
194 @dfn{localization} easy on the Amiga.
196 The idea is simple: you simply write your program using your native language
197 (English in most cases) in the same manner as you used to do before
198 localization was available, except that static strings are replaced by
199 certain function calls. Another function call enables the user to select
200 another language when the program starts by loading an external file:
201 the so called @code{catalog}, from which the strings are loaded instead
202 of using the predefined strings.
204 Catalogs are independent from the program - all you need to do to add
205 another language is create a new catalog file, and this is always possible
206 without changing the program.
208 But there's additional work for the programmer: he/she needs to create the
209 catalogs, the predefined strings and some source to handle them all, i.e.
210 the functions we mentioned above. There you go: FlexCat is designed to make
211 this for you in a straighforward manner, without sacrificing any flexibility
212 when you write your source. Let us give you an example to make this more
213 clear.
215 Suppose that we want to write @file{HelloLocalWorld.c}. Our final program
216 will look like this:
218 @example
219     #include <stdio.h>
220     #include <stdlib.h>
221     #include <HelloLocalWorld_Cat.h>  /*  You @strong{must} include this! */
223     void main(int argc, char *argv[])
224     @{
225       printf("%s\\n", msgHello);
226     @}
227 @end example
229 @noindent
230 Note that this is very similar to the well known @file{HelloWorld.c}, except
231 for replacing the string "Hello, world!" with a @code{msgHello} constant.
233 These constants and the related strings are defined in a so called
234 @ref{Catalog description} file. You always start by creating a file
235 named @file{HelloLocalWorld.cd}, which could look like this:
237 @example
238     ;   Comments are allowed, of course! Each line beginning with a
239     ;   semicolon is assumed to be a comment
240     ;
241     ;   Language used by the built-in strings.
242     #language english
243     ;
244     ;   The catalog version, used for a call to Locale/OpenCatalog().
245     ;   This is different to Exec/OpenLibrary(): 0 means any catalog
246     ;   version is accepted, but other numbers shall match exactly!
247     #version 0
248     ;
249     ;   This defines a string and the ID referring to it.
250     ;   Here, number 4 means that this string shall not be shorter
251     ;   than 4 characters.
252     msgHello (/4/)
253     Hello, world!
254 @end example
256 By using FlexCat you create another two files from the catalog description:
257 the include file @file{HelloLocalWorld_Cat.h} defines the constants, whereas
258 @file{HelloLocalWorld_Cat.c} contains an array of strings and some
259 init functions.
261 You don't need to know what they do, just use them! You don't need to know
262 anything about @file{locale.library}, either.
264 However, you might be interested into knowing how these files look, and
265 most important, you might want to modify them. This is the difference
266 between FlexCat and other catalog generators: with FlexCat, you are not
267 limited to a certain format here.
269 Instead, FlexCat uses external template files, the so called
270 @ref{Source description} files. This makes it possible, for example,
271 to use catalogs with AmigaDOS 2.0, where locale.library is not
272 available. Using the source descriptions distributed with FlexCat,
273 you can create the source files with the following commands:
275 @example
276     @samp{FlexCat  HelloLocalWorld.cd  HelloLocalWorld_Cat.c=C_c.sd}
277     @samp{FlexCat  HelloLocalWorld.cd  HelloLocalWorld_Cat.h=C_h.sd}
278 @end example
280 When your program is ready, use FlexCat again to create the
281 @ref{Catalog translation} files, one for each language you would like to
282 support with them. For example, let's create a catalog translation for German:
284 @example
285     @samp{FlexCat  HelloLocalWorld.cd  NEWCTFILE  Deutsch.ct}
286 @end example
288 @noindent
289 This file would now look as follow:
291 @example
292     ## version
293     ## language
294     ## codeset 0
295     ;   Comments ar allowed, of course! Each line beginning with a
296     ;   semicolon is assumed to be a comment
297     ;
298     ;   Language used by the built-in strings:
299     ;
300     ;   The catalog version, used for a call to Locale/OpenCatalog().
301     ;   This is different to Exec/OpenLibrary(): 0 means any catalog
302     ;   version is accepted, but other numbers shall match exactly!
303     ;
304     ;   This defines a string and the ID referring to it.
305     ;   Here, number 4 means that this string shall not be shorter
306     ;   than 4 characters.
307     msgHello
309     ; Hello, world!
310 @end example
312 @noindent
313 As you can see, this looks much like typical catalog description files.
314 FlexCat includes the comments from the catalog description, even when
315 this is meaningless: note the comment on the string length, which doesn't
316 appear here as this information must be in the catalog description only.
317 All you have to do now is fill in the information on the version (a typical
318 version string like @samp{$VER: Deutsch.catalog 1.2 (06.03.03)} is expected),
319 the language of the catalog translation (here @samp{Deutsch} for German),
320 the codeset (which should usually be 0; see Locale/OpenCatalog() for
321 details) and of course the strings themselves. FlexCat includes the
322 original strings as comments, so you always know what to fill in.
324 Ultimately you create the catalogs with a command like
326 @example
327     @samp{FlexCat  HelloLocalWorld.cd  Deutsch.ct  CATALOG  Deutsch.catalog}
328 @end example
330 @noindent
331 Note that you don't need the program itself or the source files created
332 with FlexCat for the catalogs! You can create new catalogs at any time.
333 It is usually a good idea to supply a @file{FlexCat.cd} file in your
334 software distributions for users to be able to create their own catalogs.
336 What if you change the program later? Well, you simply edit the catalog
337 description and use FlexCat to update the catalog translations:
339 @example
340     @samp{FlexCat  HelloLocalWorld.cd  Deutsch.ct  NEWCTFILE  Deutsch.ct}
341 @end example
343 @noindent
344 Now all you have to do is to enter any new strings you may need.
346 @iftex
347 @vfill@eject
348 @end iftex
350 @c -------------------------------------------------------------------------
352 @node Installation
353 @chapter Installation
354 @cindex Installation
355 @cindex Requirements
356 Since FlexCat is written in pure Ansi-C (except for localization),
357 a simple recompile is all you should need to get it running on any Amiga
358 and hopefully on other machines, too. In the latter case however,
359 localization of FlexCat itself is not available.
361 This holds true also for the programs created: FlexCat is compiled using 
362 itself. All distributed source descriptions should create programs that
363 will run on any Amiga, and even any machine; for the latter however, you
364 must ensure that the LocaleBase variable is @samp{NULL}. Localization is
365 only possible as of Workbench 2.1 because @code{locale.library} is not
366 available in older releases.
368 That said, it is not impossible to offer localization even when
369 @code{locale.library} is unavailable: see the source description files
370 @file{C_c_V20.sd} and @file{C_h_V20.sd} for an example on how to use
371 @code{iffparse.library} when @code{locale.library} is not available.
372 This makes localization possible in Workbench 2.0.
374 Installing FlexCat is a pretty simple job: just copy the program to a
375 directory in your search path and select a place for the source descriptions
376 you need (the @file{xx_yy.sd} files, where @file{xx} is the programming
377 language). You probably want to set the environment variables @var{FLEXCAT.PREFS}
378 or @var{FLEXCAT_SDDIR}. See also @ref{Program start}.
380 On AmigaOS, if you want to use FlexCat in a language other than English,
381 you need to copy the respective catalog file, too. For instance, if you
382 speak German, copy @file{Catalogs/Deutsch/FlexCat.catalog} to
383 @file{Locale:Catalogs/Deutsch/} or @file{PROGDIR:Catalogs/Deutsch/}, where
384 @file{PROGDIR:} is the directory where FlexCat is installed. See also
385 @ref{Using FlexCat source}.
387 @iftex
388 @vfill@eject
389 @end iftex
391 @c -------------------------------------------------------------------------
393 @node Program start
394 @chapter Calling FlexCat from the CLI
395 @cindex CLI
396 @cindex Workbench
397 @cindex Shell
398 FlexCat is a CLI only program. The template is
399 @example
401 FlexCat CDFILE/A,CTFILE,CATALOG/K,NEWCTFILE/K,SOURCES/M,
402         WARNCTGAPS/S,NOOPTIM/S,FILL/S,FLUSH/S,NOBEEP/S,
403         QUIET/S,NOLANGTOLOWER/S,NOBUFFEREDIO/S,MODIFIED/S,
404         COPYMSGNEW/S,OLDMSGNEW/K,AUTODATE/S
406 @end example
407 @noindent
409 Please note that in order to keep FlexCat portable, the argument parsing is
410 not quite standard. Most notably, the only keywords you can (and must) specify
411 are CATALOG and NEWCTFILE (those of type "/K"). Others should be ommited,
412 since they might end up being misused as arguments. This might change in
413 a future release.
415 As of 1.9, FlexCat implements a simple preferences mechanism which allows
416 you to change the default behaviour - see @ref{Preferences}.
418 And now, let's look at the meaning of those parameters:
420 @table @strong
421 @cindex CDFILE
422 @item CDFILE
423 Name of the catalog description file to be read. This is always needed.
425 Please note that the basename of the source description is taken from
426 this file, which means that case is significant. @xref{Source description}.
428 @cindex CTFILE
429 @item CTFILE
430 Name of a catalog translation file to be read. This is required to
431 create catalogs or to update old translations using NEWCTFILE: FlexCat
432 reads both the catalog description file and the old translation, and then
433 creates a new catalog translation file containing the old strings and
434 possibly some empty lines for the new strings appearing in the catalog
435 description that were not available in the old translation.
437 @cindex CATALOG
438 @item CATALOG
439 Name of a catalog file to be created. This requires both a catalog
440 description file and a translation.
442 @cindex NEWCTFILE
443 @item NEWCTFILE
444 The new catalog translation file to be created. FlexCat reads strings
445 from CTFILE (if provided), and strings missing in the catalog translation
446 are inserted as empty lines together with a new string marker as comment,
447 usually "***NEW***". If CTFILE is ommited, the new catalog translation
448 will only contain empty strings, assuming that the user is about to write
449 a new translation from scratch; in this case, markers aren't used.
451 @cindex SOURCES
452 @item SOURCES
453 Source files to be created. These should be specified in the form
454 @samp{SOURCE=TEMPLATE}, where @file{SOURCE} is the file to be created and
455 @samp{TEMPLATE} is the name of a source description file that is going
456 to be scanned.
458 If the specified source description file cannot be found, FlexCat will try
459 to open a file with the same name in @file{PROGDIR:lib}, i.e. the @file{lib}
460 subdirectory in the directory where FlexCat lives. You can override this
461 default with the @var{FLEXCAT_SDDIR} environment variable. For example,
463 @example
464     @samp{FlexCat  FlexCat.cd  FlexCat_Cat.c=Templates/C_c_V20.sd}
465 @end example
467 @noindent
468 would first look for @file{Templates/C_c_V20.sd} in the current
469 directory; if it cannot be found and no variable @var{FLEXCAT_SDDIR}
470 exists, FlexCat will resort to @file{PROGDIR:lib/Templates/C_c_V20.sd}.
471 Should @var{FLEXCAT_SDDIR} actually exist and point to e.g. @samp{Work:Flexcat},
472 FlexCat would try with @file{Work:FlexCat/Templates/C_c_V20.sd}.
474 @cindex WARNCTGAPS
475 @item WARNCTGAPS
476 Usually FlexCat doesn't warn about string identifiers missing in the
477 catalog translation. This option enables these warnings.
479 @cindex NOOPTIM
480 @item NOOPTIM
481 If a translated string remains unchanged with respect to the original,
482 FlexCat assumes that there's no need to write it to the catalog file as
483 it will be available in its original form. However, if for any reason
484 those strings should still be written to the catalog, use this switch.
486 @cindex FILL
487 @item FILL
488 Very useful for translators.
490 While working on a large translation where many strings are still
491 empty, you may want to check how the already translated strings will
492 look like, but compiling the catalog at this stage will probably
493 give you a half working program, since a lot of strings are empty.
494 In the worst scenario, the program you are translating can even crash!
496 This switch will force FlexCat to fill the catalog with all the missing
497 strings taken from the description file, thus allowing you to check the
498 strings already translated. Note, however, that the final translation
499 should NOT be created using this switch!
501 @cindex FLUSH
502 @item FLUSH
503 If you are still making changes to your translation and checking how
504 does it look at the same time, most likely you will have to keep using
505 the @file{AVAIL FLUSH} command to expunge the old catalog from memory,
506 because AmigaOS treats catalogs just like libraries, fonts, device
507 handlers, etc.: they remain loaded until memory gets too low or a
508 memory flush is forced.
510 If you specify this switch while creating the catalog, FlexCat will
511 automatically flush all unused resources from memory just like
512 @file{AVAIL FLUSH} would. Bear in mind however, that this will only
513 help if the program you are translating is not currently running,
514 otherwise chances are that the catalog is locked and cannot be expunged
515 from memory.
517 Example:
519 @example
520     @samp{FlexCat  Test.cd  Test.ct  CATALOG  Test.catalo g FLUSH}
521 @end example
523 @cindex NOBEEP
524 @item NOBEEP
525 Since version 1.9, FlexCat will call DisplayBeep() to notice you about
526 any problem. This is very useful when you call FlexCat from an environment
527 without an standard output (e.g. with an AmigaDOS script, using a button
528 in DOpus, etc). While FlexCat is smart enough to beep only once even if
529 20 warnings are reported in a row, you may still want to disable this
530 feature completely by using this switch.
532 @cindex NOLANGTOLOWER
533 @item NOLANGTOLOWER
534 Normally FlexCat will switch the #language entry argument taken from the
535 translation to lowercase using utility.library, which in turn calls
536 locale.library if it is available. However, it has been reported that the
537 conversion tables available with some languages (e.g. Czech) are buggy,
538 and lead to an incorrect conversion. As a workaround, this switch
539 provides the means to avoid this procedure to happen at all, but then
540 you will have to keep the #language name lowercase manually.
542 If your locale has this problem, you're highly encouraged to report it
543 to the AmigaOS maintainers, or to someone that may pass the report on
544 to them. Bear in mind that other tools will also produce wrong results
545 if this is the case, possibly with a far more undesirable effect.
547 @cindex NOBUFFEREDIO
548 @item NOBUFFEREDIO
549 Buffered I/O gives better performance for most applications doing intensive
550 input/output, and this is also the case with FlexCat especially on
551 systems where polling devices are involved, like (E)IDE drives, though
552 even users of DMA based systems (SCSI) will benefit. FlexCat uses two
553 2kB buffers, but if for some reason you want do disable this feature
554 completely, just use this switch.
556 @cindex MODIFIED
557 @item MODIFIED
558 Makes FlexCat to compile a catalog ONLY if the description or translation
559 file have changed since the last time: if the catalog file datestamp is
560 newer than any of the description or translation, FlexCat will simply
561 quit without doing anything.
563 This option comes in handy when using FlexCat in a makefile, possibly
564 compiling several catalogs at once when changes are done to the sources.
566 Example:
568 @example
569     @samp{FlexCat File.cd File.ct CATALOG File.catalog MODIFIED}
570 @end example
572 @cindex QUIET
573 @item QUIET
574 Prevents FlexCat from giving warning messages, i.e. only errors will be
575 reported. Example:
577 @example
578     @samp{FlexCat File.cd File.ct QUIET}
579 @end example
581 @cindex COPYMSGNEW
582 @item COPYMSGNEW
583 When updating an old translation using an updated description file,
584 FlexCat will mark all newly added strings with a @var{***NEW***} string
585 (see the @ref{Preferences} chapter for how to customize this string),
586 which is very useful to quickly find later the new things added since
587 the last update. Unfortunately, previous versions of FlexCat (pre 2.2)
588 didn't copy those markers over from the old translation, which forced
589 translators to either update only complete translations where no markers
590 were left, or to somehow copy them by themselves.
592 Since 2.2 however, FlexCat pays attention to these markers and will copy
593 them to the new translation file if this switch is used. Example:
595 @example
596     @samp{FlexCat New.cd Old.ct NEWCTFILE Updated.ct COPYMSGNEW}
597 @end example
599 By default, COPYMSGNEW searches for the @var{***NEW***} string and treats
600 it as the new string marker. If you were using a different string, you
601 will need to specify it using the OLDMSGNEW keyword explained below.
603 @cindex OLDMSGNEW
604 @item OLDMSGNEW
605 This parameter only makes sense when combined with COPYMSGNEW. By default,
606 COPYMSGNEW searches for the @var{***NEW***} string and treats it as the
607 new string marker, copying it to the updated translation; however, if you
608 were using a different string, you need to specify it using OLDMSGNEW,
609 otherwise FlexCat won't find it. Example:
611 @example
612     @samp{FlexCat New.cd Old.ct NEWCTFILE Updated.ct COPYMSGNEW OLDMSGNEW=**Neu**}
613 @end example
615 @cindex NOSPACE
616 @item NOSPACE
617 *FIXME* To be documented...
619 @cindex AUTODATE
620 @item AUTODATE
621 *FIXME* to be verified...
623 This switch was formerly known as NOAUTODATE, and since it was disabled
624 by default, FlexCat would always ignore the date in the translation
625 and use the current date when compiling a catalog, which in turn could
626 break havoc for people tracking changes done to a large number of
627 translations.
629 This is not the case anymore - if you really want to use the current date,
630 use this switch, otherwise the date specified in the translation will be
631 respected.
633 @end table
636 For more examples on how to use FlexCat, see the @ref{Overview}.
638 @iftex
639 @vfill@eject
640 @end iftex
642 @c -------------------------------------------------------------------------
644 @node Preferences
645 @chapter Changing the default behaviour
646 @cindex Preferences
647 @cindex flexcat.prefs
648 @cindex NEW_MSG
649 @cindex SDDIR
650 As of 1.9, FlexCat implements a simple preferences mechanism - by
651 using the @var{FLEXCAT.PREFS} environment variable, you can change
652 the default behaviour.
654 The @var{FLEXCAT.PREFS} variable is parsed using the ReadArgs() call
655 in dos.library, so all switches should be typed in one line with a space
656 as separator. Here's the template:
658 @example
659 SDDIR/K,NEW_MSG/K,WARNCTGAPS/S,NOOPTIM/S,FILL/S,FLUSH/S,NOBEEP/S,QUIET/S,
660 COPYMSGNEW/S,OLDMSGNEW/K,AUTODATE/S
661 @end example
663 @strong{NEW_MSG} can be used to customize the text that FlexCat uses to
664 mark new strings appearing while updating an old translation using a
665 new description. The default string is @var{***NEW***}.
667 Note concerning SDDIR: when creating source files, FlexCat checks the
668 following places (in this order):
670 @enumerate
671 @item the current directory
672 @item the directory set in the preferences
673 @item the directory set by the @var{FLEXCAT_SDDIR} variable
674 @item the @file{PROGDIR:lib} directory
675 @end enumerate
677 Therefore, using both the variable and @var{FLEXCAT_SDDIR} you can use
678 two custom descriptors directories simultaneously.
680 For detailed information about the other keywords ands switches, read the
681 @ref{Program start} chapter.
683 @iftex
684 @vfill@eject
685 @end iftex
687 @c -------------------------------------------------------------------------
689 @node Catalog description
690 @chapter Catalog description files
691 @cindex Catalog description
692 @cindex .cd
693 A catalog description file contains four kinds of lines:
695 @table @strong
696 @item Comments
697 Any line where a semicolon (';') exists in the first column is assumed
698 to be a comment, and therefore ignored.
700 @item Command lines
701 Lines beginning with a hash character ('#') are taken as commands. Commands
702 are case insensitive, here's the list of commands supported by FlexCat:
704 @table @code
705 @item #language <string>
706 Specifies the default language used by the program, which should match
707 the language used in the catalog description file. Default is
708 @code{#language english}.
710 @item #version <number>
711 Specifies the version number of catalogs that will be opened and used
712 by the program. Note that this number must match @strong{exactly} and not
713 differ from the version number opened by @cite{Exec/OpenLibrary()}.
714 Number 0 is special: it means that any catalog version will be accepted.
715 It is also the default value. See @file{Locale/OpenCatalog} for further
716 information on catalog languages and versions.
718 @item #lengthbytes <number>
719 Instructs FlexCat to put the given number of bytes before a string containing
720 its length. The length is the number of bytes in the string without length
721 bytes plus a trailing @samp{NUL} byte (catalog files and therefore catalog
722 strings will have a trailing @samp{NUL} byte - this is not always true for
723 the default strings, depending on the source description file).
725 @samp{<number>} must be between 0 and @math{sizeof(long)=4}. Default is @samp{#lengthbytes 0}.
727 @item #basename <string>
728 Sets the basename of the @ref{Source description}, overriding the basename
729 specified with CDFILE at the command line. @xref{Program start}.
730 @end table
732 @item Description lines
733 They declare a string. They look like @samp{IDSTR (ID/MinLen/MaxLen)} where
735 @itemize @minus
736 @item @samp{IDSTR} is an identifier using the characters a-z, A-Z and 0-9
737 @item @samp{ID} is an unique number, whereas @samp{MinLen} and @samp{MaxLen}
738 are the minimum and maximum lengths acceptable for the translated string,
739 respectively. All three are optional, in which case @cite{(//)} shall be
740 there; in this case, FlexCat chooses a number and assumes that there are
741 no restrictions on the string length. As a general rule, if you don't need
742 the ID's when creating the description file, don't use them!
743 @end itemize
745 @item String lines
746 @cindex Control characters
747 @cindex Ascii-Code
748 They contain the string itself and nothing else. Certain control characters
749 can be used here, introduced with a backslash:
751 @itemize @minus
752 @item @samp{\\b} for the backspace character (ASCII 8)
753 @item @samp{\\c} for the Control Sequence Introducer (ASCII 155)
754 @item @samp{\\e} for Escape (ASCII 27)
755 @item @samp{\\f} for the formfeed character (ASCII 12)
756 @item @samp{\\g} for the displaybeep character (ASCII 7)
757 @item @samp{\\n} for the linefeed (newline) character (ASCII 10)
758 @item @samp{\\r} for the carriage return (ASCII 13)
759 @item @samp{\\t} for TAB (ASCII 9)
760 @item @samp{\\v} for the vertical TAB (ASCII 11)
761 @item @samp{\\)} for the closing parenthesis which is possibly needed
762 as part of a @samp{(..)} sequence, see @ref{Source description}
763 @item @samp{\\\\} for the backslash itself
764 @item @samp{\\xHH} to get the character corresponding to ASCII code @samp{HH},
765 where @samp{HH} is an hex code
766 @item @samp{\\OOO} for the character corresponding to ASCII code @samp{OOO},
767 where @samp{OOO} is an octal code
768 @end itemize
770 Lastly, a single backslash at the end of a line forces a concatenation with
771 the following line, making it possible to use very long strings without
772 sacrificing readability. FlexCat makes no assumptions on string length.
773 @end table
775 A string is therefore declared with an identifier and a line containing
776 the string itself. For example,
778 @example
779     msgHello (/4/)
780     Hello, this is English!\\n
781 @end example
783 @noindent
784 @cindex FlexCat.cd
785 The ID is missing here, so FlexCat chooses a suitable number. Number 4
786 tells FlexCat that the string must not have less than four characters.
787 See the @file{FlexCat.cd} file for some real examples.
789 @iftex
790 @vfill@eject
791 @end iftex
793 @c -------------------------------------------------------------------------
795 @node Catalog translation
796 @chapter Catalog translation files
797 @cindex Catalog translation
798 @cindex .ct
799 Catalog translation files are very similar to catalog descriptions, but
800 they use different commands and contain no information on IDs and lengths,
801 as this data is taken from the catalog description file. All strings
802 declared in the description should be present in the translation, and
803 no other strings should appear.
805 These are the commands allowed in catalog translations:
807 @table @code
808 @item ## version <string>
809 Contains the catalog version as an AmigaDOS version string. Example:
811 @example
812     ## version $VER: FlexCat.catalog 8.3 (06.03.2003)
813 @end example
815 The version number of this catalog is 8, therefore the catalog description
816 file shall be either version 0 or 8 for the translation to be usable.
818 You can replace the date part (06.03.2003 in this example) with the
819 special keyword @samp{$TODAY}; when the catalog is compiled, @samp{$TODAY}
820 will be automatically replaced by the current date (note however that ONLY
821 the first instance of @samp{$TODAY} in the version string will be replaced).
822 Example:
824 @example
825     ## version $VER: FlexCat.catalog 8.3 ($TODAY)
826 @end example
828 Note that versions 2.6 - 2.6.6 of FlexCat used to completely ignore the
829 date in the translation and use the current date. This is no longer the
830 case with 2.6.7 onwards, unless you use the AUTODATE switch.
832 In addition, FlexCat automatically converts a "program.ct" instance in
833 the version string to "program.catalog" in the compiled catalog.
835 @c FIXME: The following line *is* an outrageous hack to prevent
836 @c        CVS from doing its thing, but will do until I find a
837 @c        better solution.
838 @c FIXME: The template doesn't match the description! You suck!
840 @item ## rcsid @dmn{$}Date@dmn{$} @dmn{$}Revision@dmn{$} @dmn{$}Id@dmn{$}
841 This can be used in conjunction with a revision control system instead
842 of @code{## version}. @samp{Date} becomes the date in the format @samp{yy/mm/dd},
843 while @samp{time} is the time (ignored) and @samp{rev} is the revision.
845 @item ## name <name>
846 This one is supported mainly for compatibility with CatComp. It replaces
847 the @samp{name} argument in the @code{## rcsid} command.
849 @item ## language <string>
850 The language used in the translation, which of course should be different
851 to the one used in the description. The @samp{## language} and @samp{## version}
852 commands must always be present in a catalog translation.
854 @item ## codeset <number>
855 Should be 0 unless the translation is targetted at V50, in which case
856 it should be set to the code set used in the translation, e.g. 5 for
857 ISO-8859-5. Defaults to 0.
859 @item ## chunk <ID> <string>
860 Adds a chunk ID to the catalog consisting on the given string.
861 Usually one uses this to add comments to the catalog, as in
863 @example
864     ## chunk AUTH German catalog translation by Jochen Wiedmann
865     ## chunk ANNO Generated by FlexCat
866 @end example
868 @end table
870 @cindex german.ct
871 The string given as example in the @ref{Catalog description} chapter
872 could turn into this in the catalog translation:
874 @example
875     msgHello
876     Hallo, dies ist deutsch!\\n
877 @end example
879 @noindent
880 See @file{german.ct} for an actual catalog translation.
882 @iftex
883 @vfill@eject
884 @end iftex
886 @c -------------------------------------------------------------------------
888 @node Source description
889 @chapter Source description files
890 @cindex Source description
891 @cindex .sd
892 This is the special part of FlexCat. If you have read this manual from
893 the beginning, surely you haven't yet seen anything that CatComp, KitCat
894 and others don't offer already.
896 The source created should be easy to use without losing flexibility.
897 Any programming language should be supportable, and so should any special
898 requirements you may have. This may seem like a contradiction, but FlexCat's
899 proposition to this are the @dfn{source description files} containing a
900 template of the source to be created. These files are just as editable as
901 catalog description and catalog translation files are; therefore, FlexCat
902 can potentially create the code required to fit your particular needs.
904 Source description files are searched for certain symbols, which then will
905 be replaced with certain values. Possible symbols are the backslash
906 characters we have already seen, as well as sequences beginning with
907 a @samp{%} character, which surely rings a bell for C programmers.
909 @table @samp
910 @item %b
911 Basename of the catalog description - see @ref{Program start}.
913 @item %v
914 Version number of the catalog description. Careful here - do not mix
915 this up with the version used in the catalog translation.
917 @item %l
918 Language used in the catalog description file. Note that this is inserted
919 as a string - see @samp{%s} below.
921 @item %n
922 Number of strings in the catalog description.
924 @item %%
925 The @samp{%} character itself.
926 @end table
928 However, the most important sequences are listed below. These sequences
929 represent the catalog strings in different ways. Lines containing one or
930 more of these symbols are repeated for any string.
932 @table @samp
934 @item %i
935 Identifier taken from the catalog description.
937 @item %nd
938 @itemx %nx
939 @itemx %nc
940 String ID in decimal, hexadecimal and octal characters, respectively.
941 The @samp{n} number tells FlexCat how many characters the ID should use
942 (the string will be padded with zeros at the left).
944 You may omit @samp{n} if you want - in this case, the ID will just take
945 the number of characters it needs.
947 @item %e
948 Number of this string. The counter begins at 0.
950 @item %s
951 The string itself. How it will be inserted depends on the programming
952 language, and can be controlled using the commands @samp{##stringtype}
953 and @samp{##shortstrings} (see below).
955 @item %na
956 The string ID. The difference between @samp{%na} and e.g. @samp{%nx} is that
957 @samp{%na} produces string IDs @strong{parted} to single bytes. For
958 example, @samp{%2a} in a source descriptor will produce @samp{\\x00\\0x20}.
960 You may omit @samp{n}, in which case the ID will take exactly 4 bytes.
962 @item %nt
963 Length of the string. Please note that the result value is always @strong{even}.
965 @item %z
966 Should be used together with @samp{%nt}. Since @samp{%nt} always returns
967 an even value, having a descriptor line like
969 @example 
970     static const char Block[] =
971     @{
972          "%2a" "%2t" %s "%z"
973     @};
974 @end example
976 might lead to problems especially while parsing such a table, since @samp{%2t}
977 might be even whereas the length of the real string @samp{%s} could be odd!
978 This would mean that while parsing you would read or skip one byte too much,
979 and you know the consequences of that, don't you?
981 To avoid such problems, @samp{%z} was introduced: FlexCat will replace it
982 with as many bytes (@samp{\\x00}) are needed to make the string length even.
983 For instance, if a string is 3 bytes long, @samp{%nt} will return @samp{4}
984 and @samp{%z} will add one @samp{\\x00}
986 @item %(...)
987 Inserts the text between the parenthesis for any string except the last one.
988 This is probably needed in arrays, where the array entries have to be separated
989 with commas, but the last entry must not be followed by a comma; in this
990 case, you could simply use @samp{%(,)}.
992 Note that no substitution of @samp{%} sequences happens within the parenthesis.
993 Backslash sequences, however, are still allowed.
995 @end table
997 The control sequences @samp{%l} and @samp{%s} create strings, but how strings
998 look in the end will depend on the language used in the program - this is why
999 the source description files allow command lines similar to those used in
1000 catalog translation files. These must begin at the first column of the
1001 line, with one command per line.
1003 Possible commands are:
1005 @table @code
1006 @item ##shortstrings
1007 Splits long strings over separate lines. This is probably not always possible
1008 or even not properly implemented into FlexCat, and thus the default is to
1009 create a single, probably very long string.
1011 @item ##stringtype <type>
1012 Tells FlexCat how strings should look like. Possible types are:
1014 @table @strong
1015 @item None
1016 No additional characters are created. An image of the string is inserted
1017 and nothing else. No output of binary characters (the backslash sequences)
1018 is possible.
1020 @item C
1021 Creates strings according to the @ref{C} language syntax: they will be preceded
1022 and followed by the double quote character (@samp{"}). Strings are split
1023 using the @samp{\\} sequence at the end of the line and @samp{"} at the
1024 beginning of the new line (the backslash is needed in macros). Binary
1025 characters are inserted using @samp{\\OOO}.
1027 @item @ref{Oberon}
1028 It's like string type C, except for the trailing backslash at the end of the
1029 line. This string type is also recommended for Modula-2.
1031 @item @ref{Assembler}
1032 Strings are created using @samp{dc.b}. Readable ASCII characters are preceded
1033 and followed by the single quote character (@samp{'}), whereas binary
1034 characters are inserted as @samp{$XX}.
1036 @item E
1037 Strings are preceded and followed by the single quote character (@samp{'}).
1038 A @samp{+} (plus) character concatenates strings which are split over
1039 separate lines. Binary characters are inserted like in C.
1040 @end table
1041 @end table
1043 Let's look now at an excerpt from the file @file{C_h.sd} creating an include
1044 file for C.
1046 @example
1047 ##stringtype C
1048 ##shortstrings
1050 #ifndef %b_CAT_H    /*  Assure that this is read only once. */
1051 #define %b_CAT_H
1054 /*  Get other include files     */
1055 #include <exec/types.h>
1056 #include <libraries/locale.h>
1059 /*  Prototypes  */
1060 extern void Open%bCatalog(struct Locale *, STRPTR);
1061 extern void Close%bCatalog(void);
1062 extern STRPTR Get%bString(LONG);
1064 /*  Definitions of the identifiers and their ID's           */
1065 /*  This line will be repeated for any string.              */
1066 #define %i %d
1068 #endif
1069 @end example
1071 For the search path used for source descriptions, see @ref{Program start}.
1073 @iftex
1074 @vfill@eject
1075 @end iftex
1077 @c -------------------------------------------------------------------------
1079 @node Using FlexCat source
1080 @chapter Including FlexCat source in your own programs
1081 @cindex Using FlexCat source
1082 @cindex FlexCat source
1083 Of course this depends on what source is created and hence on the source
1084 description. What we are talking here about are the source description
1085 files distributed with FlexCat (see @ref{Source description}).
1087 All source descriptions should allow using your program without
1088 @code{locale.library}. However, a global variable called @samp{LocaleBase}
1089 (@samp{_LocaleBase} for assembler) must be present and initialized with
1090 NULL or with a call to @cite{Exec/OpenLibrary}. No localization is possible
1091 in the former case except when using the source description @file{C_c_V20.sd}.
1092 This allows localization on 2.0 by replacing calls to @code{locale.library}
1093 with calls to @code{iffparse.library} (an @samp{IFFParseBase} variable has
1094 to be present for this, and initialized like @samp{LocaleBase}). @xref{C}.
1095 Programmers don't need to know these libraries except when creating their
1096 own source description files.
1098 There are three functions, and calling them is pretty simple:
1100 @table @code
1101 @item OpenCatalog (locale, language)
1102 This function possibly opens a catalog. The @code{locale} argument is a
1103 pointer to a Locale structure, whereas @code{language} is a string containing
1104 the name of the language that should be opened. In most cases these should
1105 both be @samp{NULL} or @samp{NIL} respectively, because the user defaults
1106 are overriden otherwise. See @cite{Locale/OpenCatalog} for details.
1108 Non object orientated languages (C, Assembler, Modula) usually call this
1109 function @code{OpenXXXCatalog}, where XXX is the basename of the application:
1110 this makes it possible to use different catalogs in the same program.
1112 If the user has @samp{Deutsch} and then @samp{Français} selected as
1113 preferred languages and the program's basename is @samp{XXX}, this will
1114 look for the following files in sequence:
1116 @example
1117     @file{PROGDIR:Catalogs/Deutsch/XXX.catalog}
1118     @file{LOCALE:Catalogs/Deutsch/XXX.catalog}
1119     @file{PROGDIR:Catalogs/Français/XXX.catalog}
1120     @file{LOCALE:Catalogs/Français/XXX.catalog}
1121 @end example
1123 where @file{PROGDIR:} is the program's current directory (the order of
1124 @file{PROGDIR:} and @file{LOCALE:} can get changed in order to suppress the
1125 typical @samp{Insert volume YYY} requester).
1127 OpenCatalog is of type @code{void} (a procedure for Pascal programmers),
1128 and therefore gives no result.
1130 @item GetString (ID)
1131 Gives a pointer to the string with the given ID from the catalog description.
1132 Of course these strings are owned by @code{locale.library} and must not be
1133 modified.
1135 An example might be useful. Take the string from the catalog description
1136 example, which was called @code{msgHello}. The source descriptions
1137 declare a constant @samp{msgHello} representing the ID. This could be
1138 printed in C using e.g.
1140 @example
1141     printf("%s\\n", GetString(msgHello));
1142 @end example
1144 @item CloseCatalog (void)
1145 This function frees the catalog (i.e. the RAM allocated for it) before
1146 terminating the program. You can call this function at any time, even
1147 before OpenCatalog is called.
1149 @end table
1151 @menu
1152 * C::          FlexCat source in C programs
1153 * C++::        FlexCat source in C++ programs
1154 * Oberon::     FlexCat source in Oberon programs
1155 * Modula-2::   FlexCat source in Modula-2 programs
1156 * Assembler::  FlexCat source in Assembler programs
1157 * E::          FlexCat source in E programs
1158 * Appendix::   Multiple catalogs support
1159 @end menu
1161 @iftex
1162 @vfill@eject
1163 @end iftex
1165 @c -------------------------------------------------------------------------
1167 @node C
1168 @section FlexCat source in C programs
1169 @cindex C
1170 @cindex C_c_V20.sd
1171 @cindex C_h.sd
1172 @cindex C_c_V21.sd
1173 @cindex AutoC_c.sd
1174 @cindex AutoC_h.sd
1175 @cindex CatComp_h.sd
1176 @cindex Cat2h_c.sd
1177 @cindex Cat2h_h.sd
1178 C source consists on two parts: a @file{.c} file which should be simply
1179 compiled and linked, and an include file which should be included from any
1180 source part using catalog strings to define the IDs as macros.
1182 C compilers like SAS/C, DICE and GCC allow automatic opening of libraries
1183 and initialization of the catalogs; therefore, you don't need to call
1184 neither @code{OpenCatalog} or @code{CloseCatalog}, as your compiler
1185 does that for you already. Similarly, they call the @code{GetString}
1186 functions for all catalog strings from within @code{OpenCatalog}, which
1187 allows you to simply write @samp{msgHello} instead of @samp{GetString(msgHello)}.
1189 If you define a preprocessor symbol @code{LOCALIZE_V20} for the compiler
1190 (option @samp{-D LOCALIZE_V20} with GCC and DICE, or @samp{DEF LOCALIZE_V20}
1191 with SAS/C), you get a program which can use catalogs under OS 2.0:
1192 calls to @code{locale.library} will simply be replaced by calls to
1193 @code{iffparse.library} instead. In this case however, your program will
1194 need an option like @samp{LANGUAGE Deutsch}: a function @code{InitXXXCatalog}
1195 (@samp{XXX} being the basename of the application) should be called if
1196 this option is present, receiving the language name as parameter.
1197 This option is ignored, of course, if @code{locale.library} is available.
1199 Even OS 1.3 could be supported in this fashion, but then again it would
1200 be pointless to do it at this day and age.
1202 Bear in mind that you lose some functionality with this source description;
1203 for example, you cannot supply a @code{Locale} structure to @code{OpenCatalog}.
1204 However, 95% of applications won't miss anything, while others need to modify
1205 the source description.
1207 For a sample program using these source descriptions, see the @ref{Overview}.
1209 @noindent
1210 @samp{NOTES}
1212 As of 1.9, the FlexCat distribution archive contains a @file{CatComp_h.sd}
1213 source descriptor, which can be used with programs utilizing more than
1214 one catalog at the same time. Give it a look to see how to update other
1215 source descriptors.
1217 There's also another new source descriptor contributed by Magnus Holmgren
1218 <lear@@algonet.se>. The @file{Cat2h_c.sd} and @file{Cat2h_h.sd} files contain
1219 source descriptors that generate code similar to the one generated by Cat2h
1220 by Nico François (and also Cat2Inc by Magnus Holmgren ;) using a somewhat
1221 different approach to string handling, which is both small and fast.
1223 Rather than storing all strings in an array and scan that one each time
1224 (like CatComp normally does; there are ways around that though), the first
1225 two bytes of a string contain the ID. Then, the GetString() function,
1226 which takes a string as argument, reads these two bytes into a long
1227 word, and the string ID and default string are then known.
1229 In addition, FlexCat 1.9+ is capable of generating that kind of output,
1230 using the %a command. Actually, the files included use %2a, and thus only
1231 two ID bytes per string are generated, like Cat2h does. This should be
1232 enough for most applications. If you change the length, remember that the
1233 GetString() function needs to be changed accordingly.
1235 The generated header file defines all strings, and the source file contains
1236 code to open/close the catalog (with autoinit code for SAS/C and DICE), and
1237 a suitable GetString function.  A quick look at the generated code should
1238 probably be enough to gather all the details.
1240 The code does not currently support multiple catalogs, nor changes to the
1241 version number and built-in language. This is easy to add though, for
1242 example using %b for all names and references that need to be unique,
1243 like Get%bString().
1245 @iftex
1246 @vfill@eject
1247 @end iftex
1249 @c -------------------------------------------------------------------------
1251 @node C++
1252 @section FlexCat source in C++ programs
1253 @cindex C++
1254 @cindex C++_cc.sd
1255 @cindex C++_h.sd
1256 @cindex C++_CatalogF.cc
1257 @cindex C++_CatalogF.h
1258 Using FlexCat source in C++ programs is extremely comfortable: almost
1259 everything is done by a special class implemented in the @file{C++_CatalogF.cc}
1260 and @file{C++_CatalogF.h} files. All you have to do is rename these files
1261 as @file{CatalogF.cc} and @file{CatalogF.h}, compile them and create and
1262 compile two additional files using the source descriptions @file{C++_cc.sd}
1263 and @file{C++_h.sd}; the former will create a file with the strings (which
1264 must also be compiled, of course), whereas the latter will be included into
1265 your own program. A C++ program which uses FlexCat source will look like this:
1267 @example
1268     #include <iostream.h>
1269     extern "C"
1270     @{
1271     #include <clib/exec_protos.h>
1272     @}
1273     #include "CatalogF.h"
1274     #include "HelloLocalWorld_Cat.h"
1276     struct LocaleBase *LocaleBase = 0;
1278     int main()
1279     @{ //  You must open the library here, even if your compiler supports
1280       //  Auto-Opening: This will usually break if the locale.library
1281       //  is not present. This is not what we want here as we just use
1282       //  the builtin strings in that case.
1283       LocaleBase = (struct LocaleBase *) OpenLibrary("locale.library", 38);
1285       const CatalogF cat(0, 0, HelloLocalWorld_ARGS);
1287       cout >> cat.GetString(msgHelloLocalWorld);
1289       if (LocaleBase)
1290           CloseLibrary(LocaleBase);
1291     @}
1292 @end example
1294 A modified @file{libauto.a} for GCC is available which will even allow
1295 you to remove the lines concerning the @code{LocaleBase} variable.
1297 @iftex
1298 @vfill@eject
1299 @end iftex
1301 @c -------------------------------------------------------------------------
1303 @node Oberon
1304 @section FlexCat source in Oberon programs
1305 @cindex Oberon
1306 @cindex Oberon_V38.sd
1307 @cindex Oberon_V39.sd
1308 @cindex AmigaOberon
1309 @cindex Oberon-A
1310 Several source descriptions are available:
1312 @itemize @minus
1313 @item @file{AmigaOberon.sd} is designed for the current version of the
1314 @code{AmigaOberon} compiler
1316 @item @file{Oberon_V39.sd} is for older versions
1318 @item @file{Oberon_V38.sd} uses @file{Locale.mod} from Hartmut Goebel.
1320 @item @file{Oberon-A.sd} is of course targetted at @code{Oberon-A}
1321 @end itemize
1323 The function prototypes are:
1325 @example
1326     XXX.OpenCatalog(loc: Locale.LocalePtr; language : ARRAY OF CHAR);
1327     XXX.GetString(num: LONGINT): Exec.StrPtr;
1328     XXX.CloseCatalog();
1329 @end example
1331 where @samp{XXX} is the basename from the @ref{Source description}.
1333 Finally, let's see a sample program using FlexCat source:
1335 @example
1336     MODULE HelloLocalWorld;
1338     IMPORT  x:=HelloLocalWorld_Cat; Dos;
1340     BEGIN
1341       x.OpenCatalog(NIL, "");
1343       Dos.PrintF("%s\\n", x.GetString(x.msgHello));
1345       (* Catalog will be closed automatically       *)
1346       (* when program exits.                        *)
1347     END Anything;
1348 @end example
1351 @iftex
1352 @vfill@eject
1353 @end iftex
1355 @c -------------------------------------------------------------------------
1357 @node Modula-2
1358 @section Flexcat source in Modula-2 programs
1359 @cindex Modula-2
1360 @cindex Modula2Def.sd
1361 @cindex Modula2Mod.sd
1362 Modula-2 supports a module concept similar to Oberon, whereby function
1363 names are always the same. Unlike Oberon, however, Modula-2 needs an
1364 implementation and a definition module, that's why you have to create
1365 two files using the source descriptions @file{Modula2Def.sd} and
1366 @file{Modula2Mod.sd}. These are adapted for the M2Amiga compiler.
1367 Note that you need the @file{OptLocaleL.def} file from version 4.3
1368 of the M2Amiga compiler, too.
1370 The function prototypes are:
1372 @example
1373     PROCEDURE OpenCatalog(loc : ld.LocalePtr;
1374                           language : ARRAY OF CHAR);
1375     PROCEDURE CloseCatalog();
1376     PROCEDURE GetString(num : LONGINT) : ld.StrPtr;
1377 @end example
1379 where @samp{XXX} is the basename from the source description (see
1380 @ref{Source description}).
1382 Finally, let's see a sample program using FlexCat source:
1384 @example
1385     MODULE HelloLocalWorld;
1387     IMPORT hl: HelloLocalWorldLocale,
1388            io: InOut;
1390     BEGIN
1391       hl.OpenCatalog(NIL, "");
1393       io.WriteString(hl.GetString(hl.msgHello)); io.WriteLn;
1395       hl.CloseCatalog;
1396     END HelloLocalWorld.
1397 @end example
1399 @iftex
1400 @vfill@eject
1401 @end iftex
1403 @c -------------------------------------------------------------------------
1405 @node Assembler
1406 @section FlexCat source in Assembler programs
1407 @cindex Assembler
1408 @cindex AztecAs_asm.sd
1409 @cindex AztecAs_i.sd
1410 Assembler source is created for use with the Aztec Assembler. This should
1411 not be very different to other assemblers, and you should be able to
1412 implement your own source descriptions. The source consists on two parts:
1413 an @file{.asm} file which should be simply assembled and linked, and an
1414 @file{.i} include file which defines the string IDs and has to be included
1415 by your program.
1417 FlexCat's function names are slightly modified to allow using different
1418 catalogs in a single file: they are @samp{OpenXXXCatalog}, @samp{CloseXXXCatalog}
1419 and @samp{GetXXXString}, where @samp{XXX} is the basename from the source
1420 description. The concept is taken from GadToolsBox and so far it has
1421 proved good (see also @ref{Source description}).
1423 As usual, the function result is given in d0 and the functions save registers
1424 d2-d7 and a2-a7. OpenCatalog() expects its arguments in a0 (pointer to
1425 Locale structure) and a1 (Pointer to language string), which should be NULL
1426 in most cases. GetString() expects a pointer in a0. You should not care about
1427 where it points to.
1429 Finally, here's a sample program using FlexCat source:
1431 @example
1432 *   HelloLocalWorld.asm
1433         include "XXX.i" ; Opening this is a must. This
1434                         ; contains "xref OpenHelloLocalWorldCatalog", ...
1436         xref    _LVOOpenLibrary
1437         xref    _LVOCloseLibrary
1438         xref    _AbsExecBase
1440         dseg
1441 LocNam: dc.b    "locale.library",0
1442         dc.l    _LocaleBase,4       ; Must be present under this name
1444         cseg
1446 main:   move.l  #38,d0              ; Open locale.library
1447         lea     LocName,a1
1448         move.l  _AbsExecBase.a6
1449         jsr     _LVOOpenLibrary(a6)
1450 *   NO exit, if OpenLibrary fails
1452         sub.l   a0,a0               ; Open catalog
1453         sub.l   a1,a1
1454         jsr     OpenHelloLocalWorldCatalog
1456         lea.l   msgHello,a0         ; Get pointer to string
1457         jsr     GetHelloLocalWorldString
1458         jsr     PrintD0             ; and print it
1460 Ende:
1461         jsr     CloseHelloLocalWorldCatalog ; Close Catalog
1462         move.l  _LocaleBase,a1      ; Close locale.library
1463         move.l  a1,d0               ; this test is a must for 1.3
1464         beq     Ende1
1465         jsr     CloseLibrary
1466 Ende1:
1467         rts
1468         end
1469 @end example
1471 @iftex
1472 @vfill@eject
1473 @end iftex
1475 @c -------------------------------------------------------------------------
1477 @node E
1478 @section FlexCat source in E programs
1479 @cindex E
1480 @cindex E21b.sd
1481 @cindex E30b.sd
1482 @c FIXME: The end of this paragraph could be worded better.
1483 As of 3.0, E allows programs to be split over separate modules. The
1484 following describes the usage of @file{E30b.sd}, which works with E 3.0b
1485 and later. Please note that 3.0a had significant bugs, whereas previous
1486 versions might use @file{E21b.sd} instead, which requires inserting the
1487 created source into the own source manually.
1489 @file{E30b.sd} creates a module called @file{Locale} which contains a
1490 @code{cat} variable of type @samp{catalog_XXX}, where @samp{XXX} is the
1491 basename from the source description (see @ref{Source description}).
1493 A theorethical @file{HelloLocalWorld.e} might look like this:
1495 @example
1496     MODULE '*Locale'
1497         -> Use this module
1499     DEF cat : PTR TO catalog_HelloLocalWorld
1500         -> This variable contains all the catalog strings and some
1501         -> methods. You must declare it in any module using
1502         -> Localization, but initialize it in the main module only.
1504     PROC main()
1506         localebase := OpenLibrary('locale.library', 0)
1507             -> Open locale.library; @strong{No} exit, if it cannot
1508             -> be opened: We use the builtin strings in that case.
1510         NEW cat.create()
1511         cat.open()
1512             -> As already mentioned, this is needed in the main
1513             -> module only.
1515         WriteF('\\s\\n', cat.msg_Hello_world.getstr())
1516             -> cat.msg_Hello_world one of the strings contained in
1517             -> cat. This string declares a method getstr() which
1518             -> reads the catalog and returns a pointer to the
1519             -> localized string.
1521         cat.close()
1522         IF localebase THEN CloseLibrary(localebase)
1523     ENDPROC
1524 @end example
1526 @iftex
1527 @vfill@eject
1528 @end iftex
1530 @c -------------------------------------------------------------------------
1532 @node Appendix
1533 @section Multiple catalogs support
1535 Most of currently available source descriptors cannot be used
1536 for programs opening more than one catalog. This will probably
1537 change in future releases, and corrected source descriptors will
1538 be available as part of the FlexCat distribution archive.
1540 For the time being, an example of such source descriptor file
1541 is supplied: take a look at @file{CatComp_h.sd} for how should
1542 the descriptor be defined to avoid multiple symbols, etc.
1544 In short: use @samp{%b} as prefix, suffix or other part of any name
1545 that is the vital part of your sources. If your table of strings is
1546 named @samp{STRING}, replace it with @samp{%b_STRINGS} and you won't
1547 get duplicated labels anymore.
1549 @file{CatComp_h.sd} produces sources similar to those generated by
1550 CatComp, and can be used by those who wish to use FlexCat but don't
1551 want or simply can't afford to do significant changes to their sources.
1553 @iftex
1554 @vfill@eject
1555 @end iftex
1557 @c -------------------------------------------------------------------------
1559 @node Future
1560 @unnumbered Further development of FlexCat
1561 @cindex Future
1562 @cindex FlexCat
1563 @cindex Contributions
1564 In short, the future of FlexCat depends entirely on you! Marcin dropped
1565 the development as the program fulfilled all his needs, and his TODO
1566 list was mostly empty. Suggestions, tips, bug reports and constructive
1567 criticisement are welcome, and we would like to include any new string
1568 types you may want to contribute, since this is possible with only a
1569 few minor changes.
1571 New source descriptions and extensions to support additional programming
1572 languages are especially welcome, as long as they have been proven good
1573 by testing them with an existing program. See @ref{Support} for contact
1574 info.
1576 @c -------------------------------------------------------------------------
1578 @node Support
1579 @unnumbered FlexCat support site
1580 @cindex Support
1582 The @uref{http://sourceforge.net/projects/flexcat/,Flexcat homepage} is
1583 the way to go to know about updates, file bug reports and post your
1584 enhancement requests.
1586 The current FlexCat maintainer is Ondrej Zima <amiandrew@@volny.cz>
1588 @iftex
1589 @vfill@eject
1590 @end iftex
1592 @c -------------------------------------------------------------------------
1594 @node Credits
1595 @unnumbered Credits
1596 @cindex Credits
1598 The original FlexCat author, @samp{Jochen Wiedmann}, would like to thank:
1600 @table @samp
1601 @item Albert Weinert
1602 For KitCat, the predecessor of FlexCat which was so valuable to me even
1603 if finally wasn't flexible enough, and for the Oberon source descriptions.
1605 @item Reinhard Spisser and Sebastiano Vigna
1606 For the Amiga version of texinfo. This documentation is written using it.
1608 @item The Free Software Foundation
1609 For the original version of texinfo and many other excellent software.
1611 @item Matt Dillon
1612 For DICE, and especially for DME.
1614 @item Alessandro Galassi
1615 For the original Italian catalog.
1617 @item Lionel Vintenat
1618 For the E source description and its documentation, the original French
1619 catalog and the bug reports.
1621 @item Antonio Joaquín Gómez González <u0868551@@oboe.etsiig.uniovi.es>
1622 For the C++ source descripton, the original Spanish translation of this
1623 manual, the original Spanish catalog and the very good hint on speeding
1624 up the GetString() function.
1626 @item Olaf Peters <op@@hb2.maus.de>
1627 Gor the Modula-2 source description.
1629 @item Russ Steffen <steffen@@uwstout.edu>
1630 For the suggestion of the FLEXCAT_SDDIR variable.
1632 @item Lauri Aalto <kilroy@@tolsun.oulu.fi>
1633 For the original Finnish catalog.
1635 @item Marcin Orlowski <carlos@@amiga.com.pl>
1636 For the original Polish catalog and for maintaining the Polish locale
1637 package.
1639 @item Udo Schuermann <walrus@@wam.umd.edu>
1640 For suggesting the WARNCTGAPS option and the ## chunk command.
1642 @item Christian Hoj <cbh@@vision.auc.dk>
1643 For the original Danish catalog.
1645 @item The people of #AmigaGer
1646 For answering many stupid questions and lots of fun, for example
1647 stefanb (@samp{Stefan Becker}), PowerStat (@samp{Kai Hoffmann}),
1648 ill (@samp{Markus Illenseer}), Quarvon (@samp{Jürgen Lang}),
1649 ZZA (@samp{Bernhard Möllemann}), Tron (@samp{Mathias Scheler}),
1650 mungo (@samp{Ignatios Souvlatzis}), jow (@samp{Jürgen Weinelt}) and
1651 Stargazer (@samp{Petra Zeidler}).
1653 @item Commodore
1654 For the Amiga and Kickstart 2.0. Keep on developing it and I'll be an
1655 Amiga user for the next 8 years too. ;-)
1656 @end table
1659 @samp{Marcin Orlowski}'s acknowledgements go to:
1661 @table @samp
1663 @item Jochen Wiedmann
1664 For creating FlexCat in the first place.
1666 @item Magnus Holmgren <lear@@algonet.se>
1667 For the additional source descriptor Cat2h.
1669 @item Members of the Amiga Translators' Organization <http://ato.vapor.com/ato/>
1670 For creating additional translations and updating those already existing:
1672 @itemize @minus
1673 @item Serbian catalog file by Ljubomir Jankovic <lurch@@afrodita.rcub.bg.ac.yu>
1674 @item Czech translation by Vit Sindlar <xsindl00@@stud.fee.vutbr.cz>
1675 @item Svedish translation by Magnus Holmgren <lear@@algonet.se> and Hjalmar Wikholm <hjalle@@canit.se>
1676 @item Finnish translation updated by Mika Lundell <c71829@@uwasa.fi>
1677 @item Italian translation reworked by Luca Nora <ln546991@@silab.dsi.unimi.it> and Giovanni Addabbo <gaddabbo@@imar.net>
1678 @item Slovenian translation by Damir Arh <damir.arh@@guest.arnes.si>
1679 @item Dutch translation updated by Leon Woestenberg <leon@@stack.nl>
1680 @end itemize
1682 @item Christian Hattemer <chris@@heaven.riednet.wh.tu-darmstadt.de>
1683 For the StormC source descriptors and for updating the German catalog.
1685 @item Sven Steiniger <ss37@@irz301.inf.tu-dresden.de>
1686 For the new source descriptor for E programmers (E32e.sd).
1687 @end table
1689 @iftex
1690 @vfill@eject
1691 @end iftex
1693 @c -------------------------------------------------------------------------
1695 @node History
1696 @chapter History of development
1697 @cindex History
1698 @cindex Changes
1700 The history of FlexCat development is logged in the @file{FlexCat.history}
1701 file which is an integral part of the official distribution archive.
1703 @headings off
1705 @c -------------------------------------------------------------------------
1707 @node Index
1708 @unnumbered Index
1709 @printindex cp
1711 @contents
1713 @bye