Add to String Dictionary

Verb: strDictAdd

Adds a value to the Key-Value Pair item specified for the string dictionary .

Syntax

strDictAdd [--usevariable(Boolean)] --keyvalue(StringKeyValuePair<Variant>) --key(String) --value(String) --dictionary(StringDictionary<Variant>)

Inputs

Script Designer Required AcceptedTypes Description
--usevariable Use variable Optional Boolean When enabled, allows the use of a "Key-Value Pair" variable, which is composed of the key and value of an item.
--keyvalue Key-Value Pair Only whenUse variable is True String Key Value Pair<Any> Key-Value Pair to be added to the string dictionary.
The value of the Key-Value Pair item, which is required for this parameter, must be previously assigned to a variable via the Set Key-Value Pair command.
--key Key Only whenUse variable is False Text Key to be added next to a Value in the string dictionary, which makes up the Key-Value Pair.
--value Value Only whenUse variable is False Text Value that should be added to the string dictionary, next to a Key, which makes up the Key-Value Pair.
--dictionary Dictionary Required String Dictionary<Any> String dictionary that should have a Key-Value pair added to it.

Example

Example 1: Adds to a string dictionary the Key-Value Pair "color = red", entered separately in the parameters Key and Value, respectively.

defVar --name stringDictionary --type StringDictionary --innertype String
strDictAdd --key color --value red --dictionary ${stringDictionary}
logMessage --message "${stringDictionary}" --type "Info"
// After the script is executed, the Key-Value Pair is added to the data dictionary:
//[color=red]

Example 2: After enabling Key-Value Pair and assigning "Language" and "English" to the variable "keyValuePair", the command Add to String Dictionary adds to the string dictionary the value contained in this variable .

defVar --name stringDictionary --type StringDictionary --innertype String
defVar --name keyValuePair --type StringKeyValuePair --innertype String
// Assigns "Language" and "English" to the Key-Value Pair item for use in the "strDictAdd" command.
setKeyValue --keyvalue ${keyValuePair} --key Language --value English
strDictAdd --usevariable  --keyvalue ${keyValuePair} --dictionary ${stringDictionary}
logMessage --message "${stringDictionary}" --type "Info"
// After the script is executed, the Key-Value Pair is added to the data dictionary:
//[Language=English]

Remarks

The data type used in the Value parameter must be the same as the one defined for the string dictionary.

See Also

  • Dictionary Contains Key
  • Get Dictionary Value
  • Remove from Dictionary
  • Update String Dictionary