GetParmPhrase

(VTScada-Layer function. Must be called with a leading backslash.)

Description: Returns parameterized text in the currently selected language for a given phrase identifier key.
Returns: Text
Usage: Script or Steady State
Function Groups:

String and Buffer

Related to: GetPhrase | GetParmPhraseForLang | GetPhraseID
Format: \GetParmPhrase(PhraseKey, P0[, P1, P2, P3, P4, P5, P6, P7, P8, P9])
Parameters:  
PhraseKey
Required. The identifying key for a phrase. May be a string ID that uniquely identifies given text.

P0, with optional parameters through P9

or

PhraseDictionary

In versions to 12.1.38 this could be any text that will be substituted into placeholders in the phrase matching the index of the parameter. (%0 through %9)

As of version 12.1.29 this could also be a single dictionary. See comments.

Comments:

The phrase need not have the %n placeholders in ascending numerical order, and parameters can to be used more than once. Some translations may not require a parameter at all while other parameters may occur multiple times. A maximum of 10 parameters are supported.

The Language property in the caller's scope is used to specify the language name (e.g. en). Defaults to the Windows system's language.

 

If using a phrase dictionary instead of one or more text phrases, the replaceable parameters can be named rather than numbered. For example:

This report for %[TagName] was created on %[RunTime] %[RunDate]

The matching dictionary would have the form:

PhraseDict = Dictionary();
PhraseDict["TagName"] = "Station 1";
PhraseDict["RunTime"] = "2:23 PM";
PhraseDict["RunDate"] = "Feb 26, 2024";

 

As a specialized use-case, GetParmPhrase also supports the use of translation dictionaries for the PhraseKey parameter. Use the following information only in the rare case that a standard .csv file of static translations is not suitable.

Translation dictionaries should take the following form, which is used in place of the PhraseKey parameter:

System.MakeDictionary("en", "hello", "fr", "bonjour", "es", "hola");

GetParmPhrase will then return the translation corresponding to the user's current language. If the dictionary does not include a translation for the user's current language but does for the default language, then the default will be returned. If that also does not exist, then return "Missing translation" (language dependent).

Note that the phrase may not update dynamically when the content for a given key in the dictionary changes.

Translation dictionaries should not be used in most applications.

Example:

Suppose that "TPPhrase" is the key for a phrase that has English and French definitions as follows:

English: Pump is %0

French: La pompe est %0

Suppose also that "Running" is a Boolean variable you are using to monitor the pump's status. Then...

\GetParmPhrase("TPPhrase", Running ? \GetPhrase("RunningLabel") : \GetPhrase("StoppedLabel"));

... will say that the pump is running or stopped in either French or English depending on the state of the pump at the time this runs.