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.

ExpressionsBecause procedures can return a value of any type, such as an object or anarray, you can operate on the return value with any operation appropriate tothe return value type. In the syntax example just described, procname is aprocedure that returns a numeric type like integer or float, allowing you to usethe return value in the addition.If a procedure returns an object, the return value can be manipulated like anyother object. That is, you can use the dot operator (.) to access individualattributes, or you can apply a method to that object.Using the dot operator produces a variable of some kind (depending on thetype of the attribute), so you can use the resulting variable wherever othervariables can be used. For example, if the addr_proc procedure returns avariable of class ADDR that has an attribute “city,” the following expression islegal:addr_proc().city = 'New York';Because you can apply methods to the return value, and because methods canreturn values of any type, referencing can be nested on a procedure's returnvalue, for example:ret_framexec().objectsource.duplicate().nameMethods in ExpressionsThe 4GL statement, method invocation, lets you invoke a method as part of anexpression. For more information about this statement, see the LanguageReference <strong>Guide</strong> online help.When a method returns a value, it can function as an expression. In thefollowing syntax example, methodname is the name of a method that returnsa value:returnval = objectref.methodname() + 1;When you call a method as part of an expression, you must explicitly name themethod. You can use a variable for the name of a method if you assign it to avariable. For example, the following assignment is legal:a = objectref.:varmeth();However you cannot use operators when you are assigning a variable as themethod name. For example, the following expression is illegal and cannot bespecified at runtime:a = objectref.:varmeth() + 748 <strong>Programming</strong> <strong>Guide</strong>

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

Saved successfully!

Ooh no, something went wrong!