Calculator.Initialize
Calculator.Initialize
Initializes the calculator ready for calculating.
Syntax
Initialize( inputItem, variables, sectionName, sectionId, pageWidth, pageHeight )
Parameters
inputItem | Optional input text formatted in Microsoft Rich Text Format (RTF) |
which will be calculated. | |
variables | Optional xml string of the variables to initialize the calculator with |
or the file path to a legacy variable file (.vbl). | |
sectionName | Optional initial section name. |
sectionId | Optional initial section identifier. |
pageWidth | Optional output page width in twips, default is 180 twips. |
pageHeight | Optional output page height in twips, default is 260 twips. |
Remarks
The initialize method is normally used without any parameters, the optional parameters are only required for advanced usage scenarios.
The inputItem is required if you're wanting to calculate an existing RTF source, for example if you were wanting to integrate Tedds with an alternative word processor you would get the RTF from the document and pass it as this parameter so that Tedds would calculate the expressions in the RTF. The inputItem is also required if you want to obtain output RTF once calculating is finished. Output is obtained by using the Calculator.GetOutput method but if no inputItem has been specified to the Initialize method then GetOutput will not return any output.
If the calculator has been used to perform a calculation and you want to save the variables so that they can be used at a later date for re-calculating then you can use the optional variables parameter to initialise the calculator with the previously saved variables. The variables from a previous calculation are retrieved by using the Calculator.GetVariables method
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"); //Get variables as XML string
Tedds 2019 – API Reference
string variables = calculator.GetVariables(); //... //Application performs other tasks or stores XML for later use //... //Initialize calculator with existing variables XML calculator.Initialize( "", variables )