[IronPython] Accessing scope variables
Sree Pillai
sree_b_pillai at yahoo.com
Thu Aug 6 20:57:28 CEST 2009
Hello,
We are hosting IronPython in our Windows forms-based application to allow our customers to write scripts. We allow customers to use our own variables within the script.
public class Variable
{
string Name;
int Value;
..
}
..
Variable v1 = new Variable("Length", 10); // Create a variable with Name=Length and Value=10
vars.Add(v1);
Variable v2 = new Variable("Width", 10);
vars.Add(v1);
vars.Add(v2);
We set custom variables in scriptScope like this.
..
foreach (IVariable aVariable in vars)
{
scriptScope.SetVariable(aVariable.Name, aVariable);
}
..
With this, user can write a function like this
def CalcArea() :
return Length * Width
In our application, we are dealing with hundreds of variables and functions. As the user deletes or modifies a Variable (here Length and Width), they would like to know where the variables are used. In this example, the variable Length and Width are used in CalcArea function. I can't find a way to identify the list of custom variables used within a function using the API.
Any suggestions? Thanks a lot.
Sree
More information about the Ironpython-users
mailing list