Represents a variable with a numeric value; usually stored in a VarsList.

Variable extends Parameter so that EasyScriptParser can easily set a simulation's initial conditions (the set of starting Variables). EasyScriptParser can then use the same mechanisms for setting or reporting values of Parameters and Variables.

Variables differ from "normal" Parameters in that a Variable does not broadcast when its value changes. Except that you can tell a Variable to broadcast on a discontinuous change, see setBroadcast.

interface Variable {
    getAsString(): string;
    getBroadcast(): boolean;
    getChoices(): string[];
    getName(opt_localized?): string;
    getSequence(): number;
    getSubject(): Subject;
    getValue(): number;
    getValues(): string[];
    incrSequence(): void;
    indexOf(): number;
    isComputed(): boolean;
    nameEquals(name): boolean;
    setBroadcast(value): void;
    setComputed(value): void;
    setFromString(value): void;
    setValue(value): void;
    setValueSmooth(value): void;
    toStringShort(): string;
}

Hierarchy (view full)

Implemented by

Methods

  • Returns whether the Variable is broadcast when it changes discontinuously.

    Returns boolean

    whether the Variable is broadcast when it changes discontinuously

  • Name of this SubjectEvent, either the language-independent name for scripting purposes or the localized name for display to user.

    The language-independent name should be the same as the English version but capitalized and with spaces and dashes replaced by underscore, see Util.toName and nameEquals.

    Parameters

    • Optional opt_localized: boolean

      true means return the localized version of the name; default is false which means return the language independent name.

    Returns string

    name of this object

  • Returns the sequence number of this Variable. The sequence number is incremented whenever a discontinuity occurs in the value of the variable. See incrSequence.

    For example, when the variables are set back to initial conditions that is a discontinuous change. Then a graph knows to not draw a connecting line between the points with the discontinuity.

    Another example of a discontinuity: if the value of an angle is kept within 0 to 2*Pi (by just adding or subtracting 2*pi to keep it in that range), when the angle crosses that boundary the sequence number should be incremented to indicate a discontinuity occurred.

    Returns number

    the sequence number of this Variable.

  • Returns the set of values corresponding to getChoices that this Parameter can be set to.

    Returns string[]

    set of values that this Parameter can be set to, in string form.

  • Increments the sequence number of this Variable, which indicates that a discontinuity has occurred in the value of this variable. This information is used in a graph to prevent drawing a line between points that have a discontinuity. See getSequence.

    Returns void

  • Returns index of this Variable within it's VarsList, or -1 if not in a VarsList.

    Returns number

    integer index number of the variable, or -1 if not in a VarsList

  • Returns whether the value is being automatically computed; setting the value of this Parameter has no effect.

    Examples of automatically computed Parameters: the variables that give the current energy of a simulation. Another example is when the size of a graph's SimView is under control of an AutoScale.

    Returns boolean

    whether the value is being automatically computed

  • Whether this SubjectEvent has the given name, adjusting for the transformation to a language-independent form of the name, as is done by Util.toName.

    Parameters

    • name: string

      the English or language-independent version of the name

    Returns boolean

    whether this SubjectEvent has the given name (adjusted to language-independent form)

  • Sets whether the Variable is broadcast when it changes discontinuously

    Parameters

    • value: boolean

      whether the Variable is broadcast when it changes discontinuously

    Returns void

  • Sets the value of this Parameter after converting the given string to the appropriate type (boolean, number or string).

    Parameters

    • value: string

      the value to set this Parameter to, in string form

    Returns void

    Throws

    if the string cannot be converted to the needed type

  • Sets the value of this Variable and increases the sequence number.

    Parameters

    • value: number

      the value to set this Variable to

    Returns void

  • Sets the value of this Variable without changing the sequence number which means it is a 'smooth' continuous change to the variable. See getSequence.

    Parameters

    • value: number

      the value of this Variable

    Returns void

  • Returns a minimal string representation of this object, usually giving just identity information like the class name and name of the object.

    For an object whose main purpose is to represent another Printable object, it is recommended to include the result of calling toStringShort on that other object. For example, calling toStringShort() on a DisplayShape might return something like this:

    DisplayShape{polygon:Polygon{'chain3'}}
    

    Returns string

    a minimal string representation of this object.

Generated using TypeDoc