Welcome to the Harris Geospatial product documentation center. Here you will find reference guides, help documents, and product libraries.

  >  Docs Center  >  Using IDL  >  Creating Objects


Creating Objects

Creating Objects

To create an object from the IDL object class library, you can use the class name as a function or use the OBJ_NEW function. The Init method for each class describes the arguments and keywords available when you are creating a new object.

For example, to create a new object from the IDLgrAxis class, you can create the object in one of two ways. The following examples use the arguments and keywords accepted by the IDLgrAxis::Init method.

Using the implicit object creation method, the call is:

myAxis = IDLgrAxis(DIRECTION = 1, RANGE = [0.040.0])

Using the OBJ_NEW function, the call is:

myAxis = OBJ_NEW('IDLgrAxis', DIRECTION = 1, RANGE = [0.040.0])

Once an object has been created, you can access and modify it as needed. When you create an object, it is persistent, meaning it exists in memory until it is destroyed. IDL automatically destroys heap variables that have gone out of scope.

You can also explicitly destroy objects using OBJ_DESTROY. You use an object reference (myAxis) to access the data associated with the object. This object reference actually accesses an object heap variable. (See Destroying Objects for more information.)

Note: If you use implicit object creation to create your objects, you should be sure to use compile_opt strictarr (or compile_opt idl2) at the top of your routine. This will avoid any confusion in the IDL compiler between the use of parentheses for array indexing and the use of parentheses for function calls. See Array Subscript Syntax for details on array indexing, and compile_opt for information on different compile options.

© 2018 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us