Skip to content

Register_Object

See Also: Forward Declaring Objects, Get, Object

Purpose

To allow references to an object in expressions at points in the program prior to the point at which the object is defined.

Syntax

Register_Object {object-name}

What It Does

Objects can be referred to in programs by their "access methods". Before any object can be referred to, the compiler must know the name of the object. If you wish to refer to an object before it has been defined, the Register_Object command allows you to predefine the object.

The Register_Object command defines the symbol get_objectname. This is actually a function that is translated by the system for each object that is created. The function returns the absoluteobject_id of the named object.

Register_Object oName

You may not assign an object the same name as a function or a property. If you attempt to do so, an error will be declared. For this reason, developers often preface object names with the letter "o". This ensures that the object will not share the same name as a function and makes it easier to identify object names within your code.

The Register_Object command is typically used with objects referenced in on_item, on_key, or entry_item commands. It is a misuse of the command to register an object for use as another object's property at points prior to the referenced object's creation. When this is done, various properties of the undefined object are not available for access by the using object, and the assignment will fail.

Notes

  • As of DataFlex 12.0, the compiler will automatically recognize all objects within a file and files used by this file, without needing to explicitly register each object. This dramatically reduces the number of Register_Object statements needed.