getLangIdx()

The function getLangIdx() returns the sequence number of the passed language (language that has been passed as a parameter) from the project config file. If you, for example, pass the language ID "ru_RU.utf8" (Russian) as a parameter and this language is on the third place in the config file, the function returns 2. The function returns 2 instead of 3 because the index of the languages in the config file starts at 0.

Synopsis

int getLangIdx(string id);

int getLangIdx(int id);

Parameters

Parameter Description
id Language ID. The language identifier from the lang.dir file in <wincc_oa_path>/nls from the first column of the file, for example, string ID ="ru_RU.utf8" (for Russian). The language identifier can also be an integer. In this case, you can find the language numbers of the different languages in the lang.nt file in <wincc_oa_path>/nls.

Return value

If successful, the function returns the index (starting at 0) or in the event of an error, -1.

If the id string is used a value of 255 will be returned, if the language could not be found.

Error

If the required language is not available or an argument error.

Description

The function getLangIdx() returns the sequence number of the defined language from the project config file. If you, for example, pass the language ID "ru_RU.utf8" (Russian) and this language is on the third place in the config file, the function returns 2. The function returns 2 instead of 3 because the index of the languages in the config file starts at 0.

Example

The following example returns the sequence number of the language "ru_RU.utf8" (Russian) from the project config file. The function requires that you have created a project with Russian as a project language. You can find the language identifiers of the different languages in the lang.dir file in the directory <wincc_oa_path>/nls. In this way, you can query the sequence (from the project config file) of the desired language. In this example, a trilingual project has been used. Italian has been entered as the third language into the config file.

Figure: Config file of the project

main()
{
  int result;
  string id = "ru_RU.utf8"; // Language ID of Russian
  result = getLangIdx(id); /* Returns the sequence number of Russian from the project config file */
  DebugN("Sequence number of Russian:", result);
}

Alternatively you can also pass the language identifier as an integer.

main()
{
  int result;
  int id = 8; // Language ID of Italian
  result = getLangIdx(id); /* Returns the sequence number of
  Italian from the project config file */
  DebugN(result);
}

Assignment

Multi-language capability

Availability

CTRL