Objects

Some functions require an “object” (something to act upon). Such functions may either change the state of the object or retrieve information about it. These functions are referred to as “object functions” or “methods.” For such functions, we use the following syntax:

objectName.functionName()

Object functions work just like other functions. We’ve already looked at this example:

Box1.Append(IntVar)

Here, the Text Box object named “Box1″ is the object into which we want the Append function to place the value represented by IntVar. This function is an example of an object function that returns a value.

Here’s an example of an object function that returns a value:

MyVariable = Box1.IsVisible()

In this expression, the IsVisible function checks to see whether the object named “Box1″ is visible, then it puts the Boolean result (either “true” or “false”) into the variable named MyVariable.

In addition to interactive objects, some object functions let you access other kinds of objects. For example:

MyVariable = Number.Sqrt(2)

The Number object is simply a library of math functions, rather than an interactive object. This expression tells the Number object’s Sqrt function to calculate the square root of two and store the result into the variable named “MyVariable.”

Note: To refer to an object in an expression, that object must follow certain naming conventions. It may not begin with a number, and it may not contain any symbols other than a dollar sign ($) or an underscore (_). If it contains spaces, you can substitute underscores for them when you refer to it in an expression.

Objects