1.178 class var

Class var describes a global variable. It is a subclass of class function, which implies that a variable is expanded to its value for all methods that do not explicitly accept type function or var.

PCE global variables have global existence, but may have local binding. The most well known var objects are @receiver, @event and @arg1 ... @arg10.

A variable has a var<-_type to define legal values, a var<-_name to identify them (named var objects are used by class handle and class spatial) and a var<-_value. Note that these names start with an underscore. Thus,

get(Var, '_name', Name)

yields the name of the var object, while

get(Var, name, Name)

yields the name of the var<-_value of the var object.

Values are assigned using var->assign. Class assign defines an executable object to assign variables.

1.178.1 Using var objects explicitly

There are some common ways to exploit var objects in applications:

1.178.2 Instance variables

1.178.3 Send methods

var ->assign: value=any, scope=[{local,outer,global}]
Assign a var<-_value to the variable. The scope of this assignment is determined by the scope argument:

var ->initialise: type=[type], name=[name], value=[any]
Create a var object that may contain objects of the specified type. A var object may have an optional name and initial value.

Defaults: # type: unchecked

1.178.4 Get methods

var <-convert: name -> var
Converts name to var from @variables.

In older versions of PCE @arg1, etc. where special objects. The x, y, etc. variables appearing in formulas for class handle and class spatial where other special features. In the current implementation class var takes care of all these cases. To keep the name-as-variable as used in formulas compatible we had to introduce the name conversion mechanism.