MessageService Reference

From The Foundry MODO SDK wiki
Jump to: navigation, search

The messageservice ScriptQuery interface provides access to translated strings through message tables. These tables are simple config files with a specific format.

Dictionaries and Tables

As described in the Message Tables article, message tables consist of a table and an optional dictionary. In modo 401 and earlier, table entries were represented only by numbers, and dictionaries were used to provide a more friendly alias for each numeric entry. As of 501, table entries can be any valid string, thus eliminating the need for dictionaries. However, some legacy tables may still use dictionaries.

Prior to modo 501, looking up a message in a table via a numeric identifier was done using the syntax @table@@id@, while looking up a message from a table's dictionary was done through @table@dict@. As of 501, either method can be used for both identifier or dictionary lookups.

Attributes

The service supports three attributes.

  • msgfind
  • msgsub
  • msgcompose

msgfind

msgfind looks up a message given it’s table name and either a dictionary name or ID. The selector must be in the form of @table@@id@ or @table@dict@.

Datatype string
Example query messageservice msgfind ? @common@@2031@
Result Buy modo now!

msgsub

Various messages may contain substitution keys, or arguments. These are represented by %1, %2, etc. within the message itself. msgsub replaces each successively numbered substitution key with the string provided, and returns the newly composed message. This attribute may be called repeatedly until all of the substition keys have been replaced. Note that you must have already selected a message with msgfind before querying this attribute.

Datatype string
Example query messageservice msgsub ? "my string"
Result Here we replaced the first argument with my string.

msgcompose

msgcompose is a combination of msgfind and msgdub. The first part of the selector is similar to msgfind, containing @table@@id@ or @table@dict@. Following that is a list of arguments, each wrapped in curly braces, with one for each %1, %2, etc. to replace.

Datatype string
Example query messageservice msgfind ? {@common@@20020@ {An example argument}}
Result Info: An example argument

More Information