Variable class

The Variable class gives access to variables in Reporter. More...

The REPORTER JavaScript API provides many class constants, properties and methods. For Arup to be able to extend and enhance the API in the future any constant, property or method names beginning with a lowercase or uppercase letter are reserved.
If you need to add your own properties or methods to one of the existing classes then to avoid any potential future conflict you should ensure that the name begins with either an underscore (_) or a dollar sign ($) or the name is prefixed with your own unique identifier.
For example if company 'ABC' need to add a property called 'example' then to avoid any potential future conflict use one of:

Class functions

Member functions

Variable constants

Name Description
Variable.DESCRIPTION Show variable description when editing variables with Template.EditVariables()
Variable.FORMAT Show variable format when editing variables with Template.EditVariables()
Variable.FORMAT_FLOAT Variable has floating point number format
Variable.FORMAT_GENERAL Variable has general format
Variable.FORMAT_INTEGER Variable has integer format
Variable.FORMAT_LOWERCASE Variable has lower case format
Variable.FORMAT_NONE Variable has no format
Variable.FORMAT_SCIENTIFIC Variable has scientific format
Variable.FORMAT_UPPERCASE Variable has upper case format
Variable.NAME Show variable name when editing variables with Template.EditVariables()
Variable.PRECISION Show variable precision when editing variables with Template.EditVariables()
Variable.READONLY Show variable readonly status when editing variables with Template.EditVariables()
Variable.TEMPORARY Show variable temporary status when editing variables with Template.EditVariables()
Variable.TYPE Show variable type when editing variables with Template.EditVariables()
Variable.VALUE Show variable value when editing variables with Template.EditVariables()

Variable properties

Name Type Description
description string Variable description
format constant Variable format. Can be Variable.FORMAT_NONE, Variable.FORMAT_FLOAT, Variable.FORMAT_SCIENTIFIC, Variable.FORMAT_GENERAL, Variable.FORMAT_INTEGER, Variable.FORMAT_UPPERCASE or Variable.FORMAT_LOWERCASE
name string Variable name
precision integer Variable precision for floating point numbers.
readonly logical If Variable is read only or not.
temporary logical If Variable is temporary or not.
type string Variable type. Predefined types are "Directory", "File(absolute)", "File(basename)", "File(extension)", "File(tail)", "General", "Number" and "String". Alternatively give your own type. e.g. "NODE ID"
value string Variable value

Detailed Description

The Variable class allows you to access the name, description and value of a variable inside Reporter.
Note that if you want to get a list of the variables used in a Template you should see the variables array in the Template object.
The name, description and value properties give access to the variable name, description and value respectively.

Constructor

new Variable(template[Template], name[string], description (optional)[string], value (optional)[string], type (optional)[string], readonly (optional)[boolean], temporary (optional)[boolean])

Description

Create a new Variable. The template and name arguments MUST be given, all others are optional

Arguments

  • template (Template)

    Template object to create variable in

  • name (string)

    Name of variable

  • description (optional) (string)

    Description of variable

  • value (optional) (string)

    Variable value

  • type (optional) (string)

    Type of variable. Predefined types are "Directory", "File(absolute)", "File(basename)", "File(extension)", "File(tail)", "General", "Number" and "String". Alternatively give your own type. e.g. "NODE ID". If omitted default is "General"

  • readonly (optional) (boolean)

    If variable is readonly or not. If omitted default is false.

  • temporary (optional) (boolean)

    If variable is temporary or not. If omitted default is true.

    Returns

    Variable object

    Return type

    Variable

    Example

    To create a new Variable object called TEST with description 'test variable', type of "Number" and value '10' which is not readonly for template, templ

    var variable = new Variable(templ, "TEST", "test variable", "10", "Number", false);

    Details of functions

    GetAll(template[Template]) [static]

    Description

    Returns an array of Variable objects for all of the variables in a Template.

    Arguments

  • template (Template)

    Template to get the variables from

    Returns

    Array of Variable objects

    Return type

    Array

    Example

    To get all the variables in template t:

    var v = Variable.GetAll(t);


    GetFromName(template[Template], name[string]) [static]

    Description

    Returns the Variable object for a variable name.

    Arguments

  • template (Template)

    Template to find the variable in

  • name (string)

    name of the variable you want the Variable object for

    Returns

    Variable object (or null if variable does not exist)

    Return type

    Variable

    Example

    To get the Variable object for variable EXAMPLE in template t:

    var v = Variable.GetFromName(t, "EXAMPLE");


    Remove()

    Description

    Remove a variable
    Note that if you call this function for a Variable object, the Variable data will be deleted, so you should not try to use it afterwards!.

    Arguments

    No arguments

    Returns

    no return value

    Example

    To remove variable data:

    data.Remove();