CALC 1 Home Documentation Home Contact

CALC 1 c1 JavaScript Variable Persistence Functions

The functions varSave(), varLoad() allow JavaScript variables to be saved (persisted) in the calculator database to be loaded later.

These variables can also be edited using the Data Manager.

Typically the variables are Arrays and Objects, but they can be other data types.

 

Property Description Example Result
varSave Saves a JavaScript variable. c1.varSave(c1.calcId, c1.calcData);
c1.varSave('someName', x);
 
varLoad Loads a JavaScript variable. let aObj = c1.varLoad(c1.calcId);
let y = varLoad('someName');
 
varDelete Deletes a JavaScript variable previously saved. c1.varDelete('someName');  
varList Returns an array of all of the variables in the database. let nameArray = c1.varList();  
fnDefinition Returns the function definition of a function used by a Function Calculator. The argument is the name of the function and not the title of the calculator.
This will throw an error if more then one function is found.
let script = c1.fnDefinition('functionName');  
evaluateScript Evaluates a script in the JavaScript context. This is typically used to retrieve scripts with varLoad()or fnDefinition() in Focused Calculator open scripts or Function Calculator load scripts.

c1.evaluateScript(script);
The second example avoids declaring a variable.
c1.evaluateScript(c1.fnDefinition('functionName'));

The value of the last statement.