User Variables - Advanced Use |
Top Previous Next |
FARR now supports user variables which can be set in the Options Dialog:
These user variables are an easy way for aliases and plugins to read values and settings that the user can customize.
While plugins can create their own settings dialogs, this is especially useful for alias options, such as parameters and login information. These values are stored inside the FindAndRunRobot.ini settings file.
The format for the User Variable area is: [SectionName] // comments variablename=value variablename=value
To replace a variable in an alias use: %uservar.SectionName.variablename%
To get a value from a plugin call: get_strval("uservar.SectionName.variablename") or to avoid % variable replacement in value get_strval("rawuservar.SectionName.variablename",value)
To set a value from a plugin call: set_strval("uservar.SectionName.variablename",value) or to avoid % variable replacement in value set_strval("rawuservar.SectionName.variablename",value)
A plugin can also get all variables with: get_strval("uservarlist"); get_strval("uservars");
An important feature of user variables is the ability to set some initial default values from an alias file (or a plugin). In this way when your alias is first loaded it will create sample values for the user to modify, which makes it easier to explain to the user what variables to set.
In an alias xml file include the following section:
<DefaultUserVars> [TwitterPlugin]\n // twitter plugin login settings -- change to your values\n username=YOUR_TWITTER_USERNAME\n password=YOUR_TWITTER_PASSWORD\n </DefaultUserVars>
NOTE: you need to use \n at the end of each line (because of xml removal of whitespace).
From a plugin you can do the same thing by calling the following each time your plugin is loaded:
set_strval("DefaultUserVars","[TwitterPlugin]\n// twitter plugin login settings -- change to your values\nusername=YOUR_TWITTER_USERNAME\npassword=YOUR_TWITTER_PASSWORD\n");
|