10.07.2015 Views

Programming Guide - Actian

Programming Guide - Actian

Programming Guide - Actian

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

How You Can Reference ObjectsHow You Can Enhance Performance When Declaring Reference VariablesBecause OpenROAD automatically creates an object of the specified class whenyou declare the reference variable without specifying that it defaults to null,you can enhance performance by specifying the null default in the followingcircumstances:• Declaring reference variables as parametersIf you declare a reference variable as a parameter and do not specify thatit default to null, an instance of the object is allocated in the called frameor procedure even if no argument of that type is passed to the child.If an object is passed as an argument, the implicitly created object isoverridden by the explicitly passed object. The time spent creating andremoving the implicit object can be avoided by declaring each referencevariable with default null.• Declaring local variablesSimilarly, you can avoid an implicit allocation and variable removal in localvariable declarations by specifying default null.Specify this clause when creating a variable that is used to reference anobject, as opposed to creating an instance of the object. In the 4GL codeyou can do one of the following:– Point this reference variable to an existing object of the same type.Assume that subfrm.customer.address is an entry field that isreferenced throughout a long script. To enhance performance whenworking with such a deeply nested attribute, you can point a secondreference variable to it. You can then use the second variable as anabbreviation for the first, for example:declareef1 = EntryField default null; /* instancenot required */enddeclare...ef1 = field(subfrm.customer.address);– Create an object of the same type. If you create a reference variablefor an object that does not exist and you set its default to null, youmust explicitly create the object before you can reference it, forexample:Declareef2 = EntryField default null; /* instancenot required */enddeclare...ef2 = EntryField.Create( );Note: If you do not declare a variable with default null, you do not need tocreate its object explicitly. For examples of explicit object creation, seeCreating Dynamic Frames (see page 363).116 <strong>Programming</strong> <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!