Dictionary Type Variables

A dictionary variable is a collection of key-value pairs, in which each key is mapped to a value. It is similar to an entry in a dictionary where each word has a corresponding definition or an explanation. The key is similar to the word and the value is its definition.

Within the dictionary, the key and value can be used wherever a string is used (in loops, commands, parameters, MetaBots, and so on).

The following table represents the use of Dictionary variable when used to send/ receive data to/from MetaBot Logic.
Variable Type Dictionary variable usage Description
Array

A single element within the Dictionary variable.

For example, $book{"page1"}$ - where "book" is the name of the dictionary variable and "page1" is the key whose value is used to send or receive data to or from the Array.

List

A single element within the Dictionary variable indicated by a specific key.

For example, $book{"page1"}$ - where "book" is the name of the dictionary variable and "page1" is the key whose value is used to send or receive data to or from the List.
Dictionary

The complete Dictionary variable.

For example, $book$ - where book is the name of the dictionary variable.

Rules for Dictionary Key:
  • It is not case sensitive
  • It is unique within each dictionary variable
  • It must contain at least one character other than spaces
  • It can be referenced using a string or a value variable
  • It must not contain a dollar sign ($)
  • It must not contain leading or trailing white spaces
Supported Variable Manager operations:
  • Add a key
  • Add a key and a value pair
  • Edit a key
  • Edit a value for a key
  • Delete a key and the associated value
  • Delete a key
Note:
  • If the same key with a new value is added to the Dictionary variable, then, when saving, the previous value is overwritten by the new value.
  • Dictionary variables cannot be passed between Task Bots.
  • Any entries with no key or only blank spaces in the key are automatically deleted during the initialization process.
Rules for CSV files:
  • The file extension is .csv
  • Use one key-value pair per line
  • In the key, if you have leading or trailing spaces, they will be trimmed when saving into the Dictionary variable
  • If the same key appears multiple times, only the last processed value is assigned to that key
  • If the value spans over multiple lines, it must be enclosed in double quotes
  • If the value includes comma(s), it must be enclosed in two double quotes
  • If the text within the value contains double quotes, then double quotes must be presented in the value without spaces, for example, if the actual text reads: He said,"I have to go!", and disappeared in a flash, then, it must be presented as: "He said,""I have to go!"", and disappeared in a flash."

    The following list represents a list of error conditions when processing a .csv file. The processing will continue to the next line while logging an error along with the associated line number.

    • A line without a key
    • A line with only spaces as a key
    • A line with only a key without a comma
      • The key will be added to the Dictionary variable with a null value

        A line with multiple commas

      • The text before the second comma will be entered into the variable as a valid key-value pair and the rest of the text will be ignored.
Note:
If reinitialization of an existing dictionary fails then the previous key-value data of the dictionary is preserved.