getCatStr()

This function exports a catalog entry.

Synopsis

string getCatStr(string catalog, string msgKey [, int lang])

Parameters

Parameter Description
catalogue Name of the catalog
msgKey Key of the message to be specified
lang Index of the language the catalog entry will be exported (= number between 0 and getNoOfLangs()-1). Default: Language of the UI. To determine the index of a project language, use the function getLangIdx().

Return value

Entry from the catalog that fits the msgKey in the current language.

The entry in the catalog needs to be saved in the correct coding (codepage) to export it using this function.

Error

If there is no catalog entry for the appropriate key, the return value contains "<key> in xxx.cat not found". With getLastError() you can check, whether the key has been found.

msgKey is restricted to 7-bit-ASCII character set, it must not contain umlauts (ä,ö,ü) and ß.

Description

First the current language will be determined. Then, the appropriate catalog will be opened in the directory <proj_path>/msg/<language>/<catalog>.cat and the entry for the specified msgKey will be read and returned in the language with index lang.

  • <proj_path>: project directory (for example, c:/WinCC OA/project name/)

  • <language>: appropriate language directory, for example, de_AT.utf8 or en_US.utf8.

  • <catalog>: There are standard catalogs such as general.cat and sc.cat and the individually created catalogs for a project.

In the catalogs, the text in the first column is referred to as msgKeys and the columns after that contain the text that will be written by getCatStr().

In addition to the Message Catalog Editor in the GEDI, the catalogs can also be viewed with any ASCII editor. In this case, the msgKeys and the text are separated by a comma (e.g. "permission, you need a higher authorization level", "permission" is the key and "you need a higher authorization level" is the text.)

If the characters "\n" are found in the text, a line break is inserted at this point ( "\n" is replaced by line feed ). If the characters "\t" are found, a tab character is inserted at this point.

If the message catalog is edited in an ASCII editor, an empty line must be left as last line, otherwise the message catalog can no longer be interpreted.

The language for a common UI is always the language of the UI. If necessary, you can select an alternate language with the parameter lang. This option is mainly used with the web server since there is no specific UI language defined for it.

Example

main()
{
string msg;
msg = getCatStr("SC", "running");
}
/* after calling getCatStr "running" occurs in the string msg */

Example of line breaks in the message catalogue:

er_msg1, This is \n an error text with \n

If the preceding example is written as output, it will appear as follows:

This is
an error text with
multiple lines!

Assignment

Multi-language capability

Availability

UI, CTRL