revert between 56095 -> 55830 in arch
[AROS.git] / tools / flexcat / doc / FlexCat_english.texinfo
blob3656ce6556377f45d16d0554e5c0f4babd8ba565
1 \input amigatexinfo
2 \input texinfo
4 @c
5 @c $Id$
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 %B
914 Basename of the catalog description in uppercase, with non
915 alphanumeric characters replaced with underscores - see @ref{Program start}.
917 @item %v
918 Version number of the catalog description. Careful here - do not mix
919 this up with the version used in the catalog translation.
921 @item %l
922 Language used in the catalog description file. Note that this is inserted
923 as a string - see @samp{%s} below.
925 @item %n
926 Number of strings in the catalog description.
928 @item %%
929 The @samp{%} character itself.
930 @end table
932 However, the most important sequences are listed below. These sequences
933 represent the catalog strings in different ways. Lines containing one or
934 more of these symbols are repeated for any string.
936 @table @samp
938 @item %i
939 Identifier taken from the catalog description.
941 @item %nd
942 @itemx %nx
943 @itemx %nc
944 String ID in decimal, hexadecimal and octal characters, respectively.
945 The @samp{n} number tells FlexCat how many characters the ID should use
946 (the string will be padded with zeros at the left).
948 You may omit @samp{n} if you want - in this case, the ID will just take
949 the number of characters it needs.
951 @item %e
952 Number of this string. The counter begins at 0.
954 @item %s
955 The string itself. How it will be inserted depends on the programming
956 language, and can be controlled using the commands @samp{##stringtype}
957 and @samp{##shortstrings} (see below).
959 @item %na
960 The string ID. The difference between @samp{%na} and e.g. @samp{%nx} is that
961 @samp{%na} produces string IDs @strong{parted} to single bytes. For
962 example, @samp{%2a} in a source descriptor will produce @samp{\\x00\\0x20}.
964 You may omit @samp{n}, in which case the ID will take exactly 4 bytes.
966 @item %nt
967 Length of the string. Please note that the result value is always @strong{even}.
969 @item %z
970 Should be used together with @samp{%nt}. Since @samp{%nt} always returns
971 an even value, having a descriptor line like
973 @example 
974     static const char Block[] =
975     @{
976          "%2a" "%2t" %s "%z"
977     @};
978 @end example
980 might lead to problems especially while parsing such a table, since @samp{%2t}
981 might be even whereas the length of the real string @samp{%s} could be odd!
982 This would mean that while parsing you would read or skip one byte too much,
983 and you know the consequences of that, don't you?
985 To avoid such problems, @samp{%z} was introduced: FlexCat will replace it
986 with as many bytes (@samp{\\x00}) are needed to make the string length even.
987 For instance, if a string is 3 bytes long, @samp{%nt} will return @samp{4}
988 and @samp{%z} will add one @samp{\\x00}
990 @item %(...)
991 Inserts the text between the parenthesis for any string except the last one.
992 This is probably needed in arrays, where the array entries have to be separated
993 with commas, but the last entry must not be followed by a comma; in this
994 case, you could simply use @samp{%(,)}.
996 Note that no substitution of @samp{%} sequences happens within the parenthesis.
997 Backslash sequences, however, are still allowed.
999 @end table
1001 The control sequences @samp{%l} and @samp{%s} create strings, but how strings
1002 look in the end will depend on the language used in the program - this is why
1003 the source description files allow command lines similar to those used in
1004 catalog translation files. These must begin at the first column of the
1005 line, with one command per line.
1007 Possible commands are:
1009 @table @code
1010 @item ##shortstrings
1011 Splits long strings over separate lines. This is probably not always possible
1012 or even not properly implemented into FlexCat, and thus the default is to
1013 create a single, probably very long string.
1015 @item ##stringtype <type>
1016 Tells FlexCat how strings should look like. Possible types are:
1018 @table @strong
1019 @item None
1020 No additional characters are created. An image of the string is inserted
1021 and nothing else. No output of binary characters (the backslash sequences)
1022 is possible.
1024 @item C
1025 Creates strings according to the @ref{C} language syntax: they will be preceded
1026 and followed by the double quote character (@samp{"}). Strings are split
1027 using the @samp{\\} sequence at the end of the line and @samp{"} at the
1028 beginning of the new line (the backslash is needed in macros). Binary
1029 characters are inserted using @samp{\\OOO}.
1031 @item @ref{Oberon}
1032 It's like string type C, except for the trailing backslash at the end of the
1033 line. This string type is also recommended for Modula-2.
1035 @item @ref{Assembler}
1036 Strings are created using @samp{dc.b}. Readable ASCII characters are preceded
1037 and followed by the single quote character (@samp{'}), whereas binary
1038 characters are inserted as @samp{$XX}.
1040 @item E
1041 Strings are preceded and followed by the single quote character (@samp{'}).
1042 A @samp{+} (plus) character concatenates strings which are split over
1043 separate lines. Binary characters are inserted like in C.
1044 @end table
1045 @end table
1047 Let's look now at an excerpt from the file @file{C_h.sd} creating an include
1048 file for C.
1050 @example
1051 ##stringtype C
1052 ##shortstrings
1054 #ifndef %b_CAT_H    /*  Assure that this is read only once. */
1055 #define %b_CAT_H
1058 /*  Get other include files     */
1059 #include <exec/types.h>
1060 #include <libraries/locale.h>
1063 /*  Prototypes  */
1064 extern void Open%bCatalog(struct Locale *, STRPTR);
1065 extern void Close%bCatalog(void);
1066 extern STRPTR Get%bString(LONG);
1068 /*  Definitions of the identifiers and their ID's           */
1069 /*  This line will be repeated for any string.              */
1070 #define %i %d
1072 #endif
1073 @end example
1075 For the search path used for source descriptions, see @ref{Program start}.
1077 @iftex
1078 @vfill@eject
1079 @end iftex
1081 @c -------------------------------------------------------------------------
1083 @node Using FlexCat source
1084 @chapter Including FlexCat source in your own programs
1085 @cindex Using FlexCat source
1086 @cindex FlexCat source
1087 Of course this depends on what source is created and hence on the source
1088 description. What we are talking here about are the source description
1089 files distributed with FlexCat (see @ref{Source description}).
1091 All source descriptions should allow using your program without
1092 @code{locale.library}. However, a global variable called @samp{LocaleBase}
1093 (@samp{_LocaleBase} for assembler) must be present and initialized with
1094 NULL or with a call to @cite{Exec/OpenLibrary}. No localization is possible
1095 in the former case except when using the source description @file{C_c_V20.sd}.
1096 This allows localization on 2.0 by replacing calls to @code{locale.library}
1097 with calls to @code{iffparse.library} (an @samp{IFFParseBase} variable has
1098 to be present for this, and initialized like @samp{LocaleBase}). @xref{C}.
1099 Programmers don't need to know these libraries except when creating their
1100 own source description files.
1102 There are three functions, and calling them is pretty simple:
1104 @table @code
1105 @item OpenCatalog (locale, language)
1106 This function possibly opens a catalog. The @code{locale} argument is a
1107 pointer to a Locale structure, whereas @code{language} is a string containing
1108 the name of the language that should be opened. In most cases these should
1109 both be @samp{NULL} or @samp{NIL} respectively, because the user defaults
1110 are overriden otherwise. See @cite{Locale/OpenCatalog} for details.
1112 Non object orientated languages (C, Assembler, Modula) usually call this
1113 function @code{OpenXXXCatalog}, where XXX is the basename of the application:
1114 this makes it possible to use different catalogs in the same program.
1116 If the user has @samp{Deutsch} and then @samp{Français} selected as
1117 preferred languages and the program's basename is @samp{XXX}, this will
1118 look for the following files in sequence:
1120 @example
1121     @file{PROGDIR:Catalogs/Deutsch/XXX.catalog}
1122     @file{LOCALE:Catalogs/Deutsch/XXX.catalog}
1123     @file{PROGDIR:Catalogs/Français/XXX.catalog}
1124     @file{LOCALE:Catalogs/Français/XXX.catalog}
1125 @end example
1127 where @file{PROGDIR:} is the program's current directory (the order of
1128 @file{PROGDIR:} and @file{LOCALE:} can get changed in order to suppress the
1129 typical @samp{Insert volume YYY} requester).
1131 OpenCatalog is of type @code{void} (a procedure for Pascal programmers),
1132 and therefore gives no result.
1134 @item GetString (ID)
1135 Gives a pointer to the string with the given ID from the catalog description.
1136 Of course these strings are owned by @code{locale.library} and must not be
1137 modified.
1139 An example might be useful. Take the string from the catalog description
1140 example, which was called @code{msgHello}. The source descriptions
1141 declare a constant @samp{msgHello} representing the ID. This could be
1142 printed in C using e.g.
1144 @example
1145     printf("%s\\n", GetString(msgHello));
1146 @end example
1148 @item CloseCatalog (void)
1149 This function frees the catalog (i.e. the RAM allocated for it) before
1150 terminating the program. You can call this function at any time, even
1151 before OpenCatalog is called.
1153 @end table
1155 @menu
1156 * C::          FlexCat source in C programs
1157 * C++::        FlexCat source in C++ programs
1158 * Oberon::     FlexCat source in Oberon programs
1159 * Modula-2::   FlexCat source in Modula-2 programs
1160 * Assembler::  FlexCat source in Assembler programs
1161 * E::          FlexCat source in E programs
1162 * Appendix::   Multiple catalogs support
1163 @end menu
1165 @iftex
1166 @vfill@eject
1167 @end iftex
1169 @c -------------------------------------------------------------------------
1171 @node C
1172 @section FlexCat source in C programs
1173 @cindex C
1174 @cindex C_c_V20.sd
1175 @cindex C_h.sd
1176 @cindex C_c_V21.sd
1177 @cindex AutoC_c.sd
1178 @cindex AutoC_h.sd
1179 @cindex CatComp_h.sd
1180 @cindex Cat2h_c.sd
1181 @cindex Cat2h_h.sd
1182 C source consists on two parts: a @file{.c} file which should be simply
1183 compiled and linked, and an include file which should be included from any
1184 source part using catalog strings to define the IDs as macros.
1186 C compilers like SAS/C, DICE and GCC allow automatic opening of libraries
1187 and initialization of the catalogs; therefore, you don't need to call
1188 neither @code{OpenCatalog} or @code{CloseCatalog}, as your compiler
1189 does that for you already. Similarly, they call the @code{GetString}
1190 functions for all catalog strings from within @code{OpenCatalog}, which
1191 allows you to simply write @samp{msgHello} instead of @samp{GetString(msgHello)}.
1193 If you define a preprocessor symbol @code{LOCALIZE_V20} for the compiler
1194 (option @samp{-D LOCALIZE_V20} with GCC and DICE, or @samp{DEF LOCALIZE_V20}
1195 with SAS/C), you get a program which can use catalogs under OS 2.0:
1196 calls to @code{locale.library} will simply be replaced by calls to
1197 @code{iffparse.library} instead. In this case however, your program will
1198 need an option like @samp{LANGUAGE Deutsch}: a function @code{InitXXXCatalog}
1199 (@samp{XXX} being the basename of the application) should be called if
1200 this option is present, receiving the language name as parameter.
1201 This option is ignored, of course, if @code{locale.library} is available.
1203 Even OS 1.3 could be supported in this fashion, but then again it would
1204 be pointless to do it at this day and age.
1206 Bear in mind that you lose some functionality with this source description;
1207 for example, you cannot supply a @code{Locale} structure to @code{OpenCatalog}.
1208 However, 95% of applications won't miss anything, while others need to modify
1209 the source description.
1211 For a sample program using these source descriptions, see the @ref{Overview}.
1213 @noindent
1214 @samp{NOTES}
1216 As of 1.9, the FlexCat distribution archive contains a @file{CatComp_h.sd}
1217 source descriptor, which can be used with programs utilizing more than
1218 one catalog at the same time. Give it a look to see how to update other
1219 source descriptors.
1221 There's also another new source descriptor contributed by Magnus Holmgren
1222 <lear@@algonet.se>. The @file{Cat2h_c.sd} and @file{Cat2h_h.sd} files contain
1223 source descriptors that generate code similar to the one generated by Cat2h
1224 by Nico François (and also Cat2Inc by Magnus Holmgren ;) using a somewhat
1225 different approach to string handling, which is both small and fast.
1227 Rather than storing all strings in an array and scan that one each time
1228 (like CatComp normally does; there are ways around that though), the first
1229 two bytes of a string contain the ID. Then, the GetString() function,
1230 which takes a string as argument, reads these two bytes into a long
1231 word, and the string ID and default string are then known.
1233 In addition, FlexCat 1.9+ is capable of generating that kind of output,
1234 using the %a command. Actually, the files included use %2a, and thus only
1235 two ID bytes per string are generated, like Cat2h does. This should be
1236 enough for most applications. If you change the length, remember that the
1237 GetString() function needs to be changed accordingly.
1239 The generated header file defines all strings, and the source file contains
1240 code to open/close the catalog (with autoinit code for SAS/C and DICE), and
1241 a suitable GetString function.  A quick look at the generated code should
1242 probably be enough to gather all the details.
1244 The code does not currently support multiple catalogs, nor changes to the
1245 version number and built-in language. This is easy to add though, for
1246 example using %b for all names and references that need to be unique,
1247 like Get%bString().
1249 @iftex
1250 @vfill@eject
1251 @end iftex
1253 @c -------------------------------------------------------------------------
1255 @node C++
1256 @section FlexCat source in C++ programs
1257 @cindex C++
1258 @cindex C++_cc.sd
1259 @cindex C++_h.sd
1260 @cindex C++_CatalogF.cc
1261 @cindex C++_CatalogF.h
1262 Using FlexCat source in C++ programs is extremely comfortable: almost
1263 everything is done by a special class implemented in the @file{C++_CatalogF.cc}
1264 and @file{C++_CatalogF.h} files. All you have to do is rename these files
1265 as @file{CatalogF.cc} and @file{CatalogF.h}, compile them and create and
1266 compile two additional files using the source descriptions @file{C++_cc.sd}
1267 and @file{C++_h.sd}; the former will create a file with the strings (which
1268 must also be compiled, of course), whereas the latter will be included into
1269 your own program. A C++ program which uses FlexCat source will look like this:
1271 @example
1272     #include <iostream.h>
1273     extern "C"
1274     @{
1275     #include <clib/exec_protos.h>
1276     @}
1277     #include "CatalogF.h"
1278     #include "HelloLocalWorld_Cat.h"
1280     struct LocaleBase *LocaleBase = 0;
1282     int main()
1283     @{ //  You must open the library here, even if your compiler supports
1284       //  Auto-Opening: This will usually break if the locale.library
1285       //  is not present. This is not what we want here as we just use
1286       //  the builtin strings in that case.
1287       LocaleBase = (struct LocaleBase *) OpenLibrary("locale.library", 38);
1289       const CatalogF cat(0, 0, HelloLocalWorld_ARGS);
1291       cout >> cat.GetString(msgHelloLocalWorld);
1293       if (LocaleBase)
1294           CloseLibrary(LocaleBase);
1295     @}
1296 @end example
1298 A modified @file{libauto.a} for GCC is available which will even allow
1299 you to remove the lines concerning the @code{LocaleBase} variable.
1301 @iftex
1302 @vfill@eject
1303 @end iftex
1305 @c -------------------------------------------------------------------------
1307 @node Oberon
1308 @section FlexCat source in Oberon programs
1309 @cindex Oberon
1310 @cindex Oberon_V38.sd
1311 @cindex Oberon_V39.sd
1312 @cindex AmigaOberon
1313 @cindex Oberon-A
1314 Several source descriptions are available:
1316 @itemize @minus
1317 @item @file{AmigaOberon.sd} is designed for the current version of the
1318 @code{AmigaOberon} compiler
1320 @item @file{Oberon_V39.sd} is for older versions
1322 @item @file{Oberon_V38.sd} uses @file{Locale.mod} from Hartmut Goebel.
1324 @item @file{Oberon-A.sd} is of course targetted at @code{Oberon-A}
1325 @end itemize
1327 The function prototypes are:
1329 @example
1330     XXX.OpenCatalog(loc: Locale.LocalePtr; language : ARRAY OF CHAR);
1331     XXX.GetString(num: LONGINT): Exec.StrPtr;
1332     XXX.CloseCatalog();
1333 @end example
1335 where @samp{XXX} is the basename from the @ref{Source description}.
1337 Finally, let's see a sample program using FlexCat source:
1339 @example
1340     MODULE HelloLocalWorld;
1342     IMPORT  x:=HelloLocalWorld_Cat; Dos;
1344     BEGIN
1345       x.OpenCatalog(NIL, "");
1347       Dos.PrintF("%s\\n", x.GetString(x.msgHello));
1349       (* Catalog will be closed automatically       *)
1350       (* when program exits.                        *)
1351     END Anything;
1352 @end example
1355 @iftex
1356 @vfill@eject
1357 @end iftex
1359 @c -------------------------------------------------------------------------
1361 @node Modula-2
1362 @section Flexcat source in Modula-2 programs
1363 @cindex Modula-2
1364 @cindex Modula2Def.sd
1365 @cindex Modula2Mod.sd
1366 Modula-2 supports a module concept similar to Oberon, whereby function
1367 names are always the same. Unlike Oberon, however, Modula-2 needs an
1368 implementation and a definition module, that's why you have to create
1369 two files using the source descriptions @file{Modula2Def.sd} and
1370 @file{Modula2Mod.sd}. These are adapted for the M2Amiga compiler.
1371 Note that you need the @file{OptLocaleL.def} file from version 4.3
1372 of the M2Amiga compiler, too.
1374 The function prototypes are:
1376 @example
1377     PROCEDURE OpenCatalog(loc : ld.LocalePtr;
1378                           language : ARRAY OF CHAR);
1379     PROCEDURE CloseCatalog();
1380     PROCEDURE GetString(num : LONGINT) : ld.StrPtr;
1381 @end example
1383 where @samp{XXX} is the basename from the source description (see
1384 @ref{Source description}).
1386 Finally, let's see a sample program using FlexCat source:
1388 @example
1389     MODULE HelloLocalWorld;
1391     IMPORT hl: HelloLocalWorldLocale,
1392            io: InOut;
1394     BEGIN
1395       hl.OpenCatalog(NIL, "");
1397       io.WriteString(hl.GetString(hl.msgHello)); io.WriteLn;
1399       hl.CloseCatalog;
1400     END HelloLocalWorld.
1401 @end example
1403 @iftex
1404 @vfill@eject
1405 @end iftex
1407 @c -------------------------------------------------------------------------
1409 @node Assembler
1410 @section FlexCat source in Assembler programs
1411 @cindex Assembler
1412 @cindex AztecAs_asm.sd
1413 @cindex AztecAs_i.sd
1414 Assembler source is created for use with the Aztec Assembler. This should
1415 not be very different to other assemblers, and you should be able to
1416 implement your own source descriptions. The source consists on two parts:
1417 an @file{.asm} file which should be simply assembled and linked, and an
1418 @file{.i} include file which defines the string IDs and has to be included
1419 by your program.
1421 FlexCat's function names are slightly modified to allow using different
1422 catalogs in a single file: they are @samp{OpenXXXCatalog}, @samp{CloseXXXCatalog}
1423 and @samp{GetXXXString}, where @samp{XXX} is the basename from the source
1424 description. The concept is taken from GadToolsBox and so far it has
1425 proved good (see also @ref{Source description}).
1427 As usual, the function result is given in d0 and the functions save registers
1428 d2-d7 and a2-a7. OpenCatalog() expects its arguments in a0 (pointer to
1429 Locale structure) and a1 (Pointer to language string), which should be NULL
1430 in most cases. GetString() expects a pointer in a0. You should not care about
1431 where it points to.
1433 Finally, here's a sample program using FlexCat source:
1435 @example
1436 *   HelloLocalWorld.asm
1437         include "XXX.i" ; Opening this is a must. This
1438                         ; contains "xref OpenHelloLocalWorldCatalog", ...
1440         xref    _LVOOpenLibrary
1441         xref    _LVOCloseLibrary
1442         xref    _AbsExecBase
1444         dseg
1445 LocNam: dc.b    "locale.library",0
1446         dc.l    _LocaleBase,4       ; Must be present under this name
1448         cseg
1450 main:   move.l  #38,d0              ; Open locale.library
1451         lea     LocName,a1
1452         move.l  _AbsExecBase.a6
1453         jsr     _LVOOpenLibrary(a6)
1454 *   NO exit, if OpenLibrary fails
1456         sub.l   a0,a0               ; Open catalog
1457         sub.l   a1,a1
1458         jsr     OpenHelloLocalWorldCatalog
1460         lea.l   msgHello,a0         ; Get pointer to string
1461         jsr     GetHelloLocalWorldString
1462         jsr     PrintD0             ; and print it
1464 Ende:
1465         jsr     CloseHelloLocalWorldCatalog ; Close Catalog
1466         move.l  _LocaleBase,a1      ; Close locale.library
1467         move.l  a1,d0               ; this test is a must for 1.3
1468         beq     Ende1
1469         jsr     CloseLibrary
1470 Ende1:
1471         rts
1472         end
1473 @end example
1475 @iftex
1476 @vfill@eject
1477 @end iftex
1479 @c -------------------------------------------------------------------------
1481 @node E
1482 @section FlexCat source in E programs
1483 @cindex E
1484 @cindex E21b.sd
1485 @cindex E30b.sd
1486 @c FIXME: The end of this paragraph could be worded better.
1487 As of 3.0, E allows programs to be split over separate modules. The
1488 following describes the usage of @file{E30b.sd}, which works with E 3.0b
1489 and later. Please note that 3.0a had significant bugs, whereas previous
1490 versions might use @file{E21b.sd} instead, which requires inserting the
1491 created source into the own source manually.
1493 @file{E30b.sd} creates a module called @file{Locale} which contains a
1494 @code{cat} variable of type @samp{catalog_XXX}, where @samp{XXX} is the
1495 basename from the source description (see @ref{Source description}).
1497 A theorethical @file{HelloLocalWorld.e} might look like this:
1499 @example
1500     MODULE '*Locale'
1501         -> Use this module
1503     DEF cat : PTR TO catalog_HelloLocalWorld
1504         -> This variable contains all the catalog strings and some
1505         -> methods. You must declare it in any module using
1506         -> Localization, but initialize it in the main module only.
1508     PROC main()
1510         localebase := OpenLibrary('locale.library', 0)
1511             -> Open locale.library; @strong{No} exit, if it cannot
1512             -> be opened: We use the builtin strings in that case.
1514         NEW cat.create()
1515         cat.open()
1516             -> As already mentioned, this is needed in the main
1517             -> module only.
1519         WriteF('\\s\\n', cat.msg_Hello_world.getstr())
1520             -> cat.msg_Hello_world one of the strings contained in
1521             -> cat. This string declares a method getstr() which
1522             -> reads the catalog and returns a pointer to the
1523             -> localized string.
1525         cat.close()
1526         IF localebase THEN CloseLibrary(localebase)
1527     ENDPROC
1528 @end example
1530 @iftex
1531 @vfill@eject
1532 @end iftex
1534 @c -------------------------------------------------------------------------
1536 @node Appendix
1537 @section Multiple catalogs support
1539 Most of currently available source descriptors cannot be used
1540 for programs opening more than one catalog. This will probably
1541 change in future releases, and corrected source descriptors will
1542 be available as part of the FlexCat distribution archive.
1544 For the time being, an example of such source descriptor file
1545 is supplied: take a look at @file{CatComp_h.sd} for how should
1546 the descriptor be defined to avoid multiple symbols, etc.
1548 In short: use @samp{%b} as prefix, suffix or other part of any name
1549 that is the vital part of your sources. If your table of strings is
1550 named @samp{STRING}, replace it with @samp{%b_STRINGS} and you won't
1551 get duplicated labels anymore.
1553 @file{CatComp_h.sd} produces sources similar to those generated by
1554 CatComp, and can be used by those who wish to use FlexCat but don't
1555 want or simply can't afford to do significant changes to their sources.
1557 @iftex
1558 @vfill@eject
1559 @end iftex
1561 @c -------------------------------------------------------------------------
1563 @node Future
1564 @unnumbered Further development of FlexCat
1565 @cindex Future
1566 @cindex FlexCat
1567 @cindex Contributions
1568 In short, the future of FlexCat depends entirely on you! Marcin dropped
1569 the development as the program fulfilled all his needs, and his TODO
1570 list was mostly empty. Suggestions, tips, bug reports and constructive
1571 criticisement are welcome, and we would like to include any new string
1572 types you may want to contribute, since this is possible with only a
1573 few minor changes.
1575 New source descriptions and extensions to support additional programming
1576 languages are especially welcome, as long as they have been proven good
1577 by testing them with an existing program. See @ref{Support} for contact
1578 info.
1580 @c -------------------------------------------------------------------------
1582 @node Support
1583 @unnumbered FlexCat support site
1584 @cindex Support
1586 The @uref{http://sourceforge.net/projects/flexcat/,Flexcat homepage} is
1587 the way to go to know about updates, file bug reports and post your
1588 enhancement requests.
1590 The current FlexCat maintainer is Ondrej Zima <amiandrew@@volny.cz>
1592 @iftex
1593 @vfill@eject
1594 @end iftex
1596 @c -------------------------------------------------------------------------
1598 @node Credits
1599 @unnumbered Credits
1600 @cindex Credits
1602 The original FlexCat author, @samp{Jochen Wiedmann}, would like to thank:
1604 @table @samp
1605 @item Albert Weinert
1606 For KitCat, the predecessor of FlexCat which was so valuable to me even
1607 if finally wasn't flexible enough, and for the Oberon source descriptions.
1609 @item Reinhard Spisser and Sebastiano Vigna
1610 For the Amiga version of texinfo. This documentation is written using it.
1612 @item The Free Software Foundation
1613 For the original version of texinfo and many other excellent software.
1615 @item Matt Dillon
1616 For DICE, and especially for DME.
1618 @item Alessandro Galassi
1619 For the original Italian catalog.
1621 @item Lionel Vintenat
1622 For the E source description and its documentation, the original French
1623 catalog and the bug reports.
1625 @item Antonio Joaquín Gómez González <u0868551@@oboe.etsiig.uniovi.es>
1626 For the C++ source descripton, the original Spanish translation of this
1627 manual, the original Spanish catalog and the very good hint on speeding
1628 up the GetString() function.
1630 @item Olaf Peters <op@@hb2.maus.de>
1631 Gor the Modula-2 source description.
1633 @item Russ Steffen <steffen@@uwstout.edu>
1634 For the suggestion of the FLEXCAT_SDDIR variable.
1636 @item Lauri Aalto <kilroy@@tolsun.oulu.fi>
1637 For the original Finnish catalog.
1639 @item Marcin Orlowski <carlos@@amiga.com.pl>
1640 For the original Polish catalog and for maintaining the Polish locale
1641 package.
1643 @item Udo Schuermann <walrus@@wam.umd.edu>
1644 For suggesting the WARNCTGAPS option and the ## chunk command.
1646 @item Christian Hoj <cbh@@vision.auc.dk>
1647 For the original Danish catalog.
1649 @item The people of #AmigaGer
1650 For answering many stupid questions and lots of fun, for example
1651 stefanb (@samp{Stefan Becker}), PowerStat (@samp{Kai Hoffmann}),
1652 ill (@samp{Markus Illenseer}), Quarvon (@samp{Jürgen Lang}),
1653 ZZA (@samp{Bernhard Möllemann}), Tron (@samp{Mathias Scheler}),
1654 mungo (@samp{Ignatios Souvlatzis}), jow (@samp{Jürgen Weinelt}) and
1655 Stargazer (@samp{Petra Zeidler}).
1657 @item Commodore
1658 For the Amiga and Kickstart 2.0. Keep on developing it and I'll be an
1659 Amiga user for the next 8 years too. ;-)
1660 @end table
1663 @samp{Marcin Orlowski}'s acknowledgements go to:
1665 @table @samp
1667 @item Jochen Wiedmann
1668 For creating FlexCat in the first place.
1670 @item Magnus Holmgren <lear@@algonet.se>
1671 For the additional source descriptor Cat2h.
1673 @item Members of the Amiga Translators' Organization <http://ato.vapor.com/ato/>
1674 For creating additional translations and updating those already existing:
1676 @itemize @minus
1677 @item Serbian catalog file by Ljubomir Jankovic <lurch@@afrodita.rcub.bg.ac.yu>
1678 @item Czech translation by Vit Sindlar <xsindl00@@stud.fee.vutbr.cz>
1679 @item Svedish translation by Magnus Holmgren <lear@@algonet.se> and Hjalmar Wikholm <hjalle@@canit.se>
1680 @item Finnish translation updated by Mika Lundell <c71829@@uwasa.fi>
1681 @item Italian translation reworked by Luca Nora <ln546991@@silab.dsi.unimi.it> and Giovanni Addabbo <gaddabbo@@imar.net>
1682 @item Slovenian translation by Damir Arh <damir.arh@@guest.arnes.si>
1683 @item Dutch translation updated by Leon Woestenberg <leon@@stack.nl>
1684 @end itemize
1686 @item Christian Hattemer <chris@@heaven.riednet.wh.tu-darmstadt.de>
1687 For the StormC source descriptors and for updating the German catalog.
1689 @item Sven Steiniger <ss37@@irz301.inf.tu-dresden.de>
1690 For the new source descriptor for E programmers (E32e.sd).
1691 @end table
1693 @iftex
1694 @vfill@eject
1695 @end iftex
1697 @c -------------------------------------------------------------------------
1699 @node History
1700 @chapter History of development
1701 @cindex History
1702 @cindex Changes
1704 The history of FlexCat development is logged in the @file{FlexCat.history}
1705 file which is an integral part of the official distribution archive.
1707 @headings off
1709 @c -------------------------------------------------------------------------
1711 @node Index
1712 @unnumbered Index
1713 @printindex cp
1715 @contents
1717 @bye