Skip to main content

Introspection Functions

Functions that provide information about variables

method

Returns an array of Objects that gives information about the methods of a variable.

Description

The object contains 4 fields:

  • name - the name of the method
  • description - description of the method if available
  • returns - the return type of the method as returned by the typeOf function
  • syntax - The syntax of the method including all the parameters

Syntax

methods(Any Var)

Example

d = Date()
print methods(d)
[
{
"description": "Returns a new Date as the next calendar day after this one",
"name": "next",
"returns": "Date",
"syntax": "next()"
}
{
"description": "Returns a new Date as the previous calendar day before this one",
"name": "previous",
"returns": "Date",
"syntax": "previous()"
}
{
"description": "Returns true if this date is a holiday using the supplied calendar",
"name": "isHoliday",
"returns": "Scalar",
"syntax": "isHoliday(Calendar \[Calendar or Scalar\] The calendar to calculate the holiday)"
}
]

properties

Returns an array of Objects that gives information about the properties on a variable.

The object contains 3 fields:

  • name - the name of the property
  • description - description of the property if available
  • type - the type of the property as returned by the typeOf function

Syntax

properties(Any Var)

Example

d = Date()
print properties(d)
[
{
"description": "Get the year",
"name": "year",
"type": "Scalar"
}
{
"description": "Get the hour of the day from 0 to 23",
"name": "hour",
"type": "Scalar"
}
...
]

typeOf

Returns a String with the type name of a variable

Syntax

typeOf(Any Var)

Description

The typeOf function returns the string name of the type of variable of the passed in variable

Example

a = "Hello"
print typeOf(a)
Scalar

variable

The variable function is used to work with dynamic variable names

Syntax

Var = variable(String)

Result

The variable that is named as the input string

Example

name="This is it"
variable(clean(name)) = TimeSeries("DAILY")
variable(clean(name)).category = "TEST"
variable(clean(name)).add("2021-05-27", 12.2)
print variable(clean(name)).get("2021-05-27").value
12.2

variables

Returns an array of Objects that gives information about all the variables in the current session.

The object contains 3 fields:

  • name - the name of the variable
  • scope - the scope of the variable, Global being the main scope
  • type - the type of the variable as returned by the typeOf function

Syntax

variables()

Example

a = "Hello"
d = Date()
print variables()
[
{
"name": "a",
"scope": "Global",
"type": "Scalar"
}
{
"name": "d",
"scope": "Global",
"type": "Date"
}
{
"name": "PROCESS",
"scope": "Global",
"type": "Process"
}
]