10.07.2015 Views

Programming Guide - Actian

Programming Guide - Actian

Programming Guide - Actian

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

How Procedure Handles Work (ProcHandle Objects)When you call a procedure in an expression, you must include the parentheseseven if you are not passing parameters to the procedure. In the followingexample, the parentheses are empty because no parameters are being passedto the dbms_error_message procedure:message 'Cannot insert graphic into thedatabase. ' +dbms_error_message();In OpenROAD, 4GL procedures can return a value of any type. You can operateon the return value with any operation appropriate to the return value type. Inthe previous example, the dbms_error_message procedure returns a textvalue. Therefore you can use the return value within the text expression.If the return value is a reference variable, you can manipulate it as any otherreference variable. For example, you can use dot notation to access a specificattribute or to invoke a method of the object.How Procedure Handles Work (ProcHandle Objects)A procedure handle (ProcHandle object) represents a global or local procedureand the scope in which to execute it. ProcHandle objects have several uses, forexample:• They let called frames call procedures declared locally in their callingframe.• They let field scripts declare local procedures that can be called fromanywhere in the frame.ProcHandle objects are useful to pass procedures to contexts in which theprocedure is not otherwise visible. They are used similarly to function pointersin the C language.For example, you could write a field script that defines its own local cleanupprocedures. In its initialize block it could insert its handles into an array ofcleanup procedure handles defined at the frame level. You can create localcleanup procedures for other field scripts as well. Later, at cleanup time, theframe can loop through the cleanup array and use the handle to call eachprocedure.How You Can Create a ProcHandle ObjectTo obtain a ProcHandle object, invoke the GetProcHandle method on a Scopeobject. The syntax is:prochandle = scope.GetProcHandle(name = string);Writing Scripts and Procedures 87

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

Saved successfully!

Ooh no, something went wrong!