Calculator.SetVariables

Updated: 17 Jan 2024

Calculator.SetVariables 

Assign all the specified variables in the calculator. 


Syntax 

SetVariables( varibales, format ) 


Parameters 

variables a string which defines the variables and their associated values and attributes 
format optional format of the variables, default is XML. 


Remarks 

 

The Calculator currently supports one format for defining variables which uses XML. The XML schema is not documented and is subject to change however the Tedds Calculator itself can be used to generate the required XML. To create the XML string create an instance of the XML calculator and initialize the calculator using Calculator.Initialize omitting all of the optional parameters. For each variable you wish to assign in the XML use Calculator.Functions.SetVar or Calculator.Functions.SetVarExpr. Once all the required variables have been assigned use Calculator.Functions.GetVariables to retrieve an XML string of all the variables which have been defined. This XML string can then be used with a second instance of the Calculator and passed to the Calculator.Initialize function. 

 

Example (C# - important semicolons may be hidden when viewed in Tedds) 

//Create calculator ICalculator calculator = new Calculator(); //Initialize first time calculator.Initialize(); //Set all required variables calculator.functions.SetVar("E", 75, "m"); calculator.functions.SetVar("N", 100, "m"); calculator.functions.SetVar("L", 275, "m"); calculator.functions.SetVar("D", 270, "m"); calculator.functions.SetVar("M", 10, "m"); calculator.functions.SetVar("S", 10, "m"); //Get variables as XML string string variables = calculator.GetVariables(); //... //Application performs other tasks or stores XML for later use //... //Initialize calculator with existing variables XML calculator.Initialize( "", variables ); //Run Co-ordinate conversion library calculation 
Tedds 2019 – API Reference 
calculator.Functions.Eval("EvalCalcItem(\"$(SysLbrDir)coordinates.lbr\" ,\"10 coordinates;Calcs\" )"); //Get results CalcValue eTarget = calculator.Functions.GetVar("E_{Target}"); CalcValue nTarget = calculator.Functions.GetVar("N_{Target}"); //Output results System.Diagnostics.Debug.WriteLine(string.Format("E_{{Target}} = {0} m", (double)eTarget.ToDouble("m"))); System.Diagnostics.Debug.WriteLine(string.Format("N_{{Target}} = {0} m", (double)nTarget.ToDouble("m"))); 

 

Was this helpful?
The feedback you give here is not visible to other users. We use your comments to improve the content.