search

Class myphysicslab.lab.model.ExpressionVariable

Provided By
Extends
All Implemented Interfaces

A Variable whose value is defined by a JavaScript expression which is evaluated at runtime.

An example of using ExpressionVariable is in myphysicslab.sims.springs.SingleSpringApp. This adds a variable whose value is sin(time):

var va = sim.getVarsList();
va.addVariable(new ExpressionVariable(va, 'sin_time', 'sin(time)',
    this.terminal, 'Math.sin(sim.getTime());'));

The variable can then be displayed in a graph.

new ExpressionVariable( varsList, name, localName, terminal, script )

Parameters
varsListmyphysicslab.lab.model.VarsList

the VarsList which contains this Variable

namestring

the name of this Variable; this will be underscorized so the English name can be passed in here. See myphysicslab.lab.util.UtilityCore#toName.

localNamestring

the localized name of this Variable

terminalmyphysicslab.lab.util.Terminal

the Terminal object used for evaluating the script

scriptstring

the JavaScript expression to evaluate that will provide the variable's value

Instance Methods