All the variables from sc.variable are defined in two places
For example tempFolder is defined :
<sc.variable name="tempFolder" value="/temp" />
and
<setting name="TempFolder" value="$(tempFolder)" />
The value of the TempFolder you can get using :
return Settings.GetSetting("TempFolder", "/temp")
where the second parameter is default value.
So I recommend to declare your variable not like a sc.variable, but like normal setting. Or if you declare like a sc.variable declare a setting with a variable parameter.
Update:
How sitecore replace this variables :
On Sitecore.Configuration.ConfigReader it has a method:
protected virtual void ReplaceGlobalVariables(System.Xml.XmlNode rootNode)
{
Assert.ArgumentNotNull(rootNode, "rootNode");
System.Xml.XmlNodeList xmlNodeList = rootNode.SelectNodes(".//sc.variable");
StringDictionary stringDictionary = new StringDictionary();
foreach (System.Xml.XmlAttribute xmlAttribute in rootNode.Attributes)
{
string name = xmlAttribute.Name;
string @string = StringUtil.GetString(new string[]
{
xmlAttribute.Value
});
if (name.Length > 0)
{
string key = "$(" + name + ")";
stringDictionary[key] = @string;
}
}
for (int i = 0; i < xmlNodeList.Count; i++)
{
string attribute = XmlUtil.GetAttribute("name", xmlNodeList[i]);
string attribute2 = XmlUtil.GetAttribute("value", xmlNodeList[i]);
if (attribute.Length > 0)
{
string key2 = "$(" + attribute + ")";
stringDictionary[key2] = attribute2;
}
}
if (stringDictionary.Count == 0)
{
return;
}
this.ReplaceGlobalVariables(rootNode, stringDictionary);
}