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 Invoke FramesFor example, in the following statement, int_var, ref_var, and array_var are allparameters; and 2, check_out_row, and videos are their assigned values,respectively:callframe myframe (int_var = 2, ref_var =check_out_row,array_var = videos);When you pass a simple variable, such as int_var, by value, any changes thatyou make to its value in the called frame are not reflected in the calling frame.For example, if myframe changes int_var to a value of 10, this change is notvisible to the frame that called myframe. When myframe closes, int_var stillhas a value of 2 in the calling frame.In contrast, when you pass a parameter that references a 4GL object or anarray variable by value, any changes that you make to the object identified bythe variable are reflected in the calling frame. This is because both arrayvariables and variables referencing 4GL objects (reference variables) arepointers. When you pass a pointer to a called frame, both the called and thecalling frame have a pointer to the same object. Consequently, any changes tothat object in the called frame are visible in the calling frame when the calledframe closes.To pass a parameter by reference, you use the byref keyword. The syntax is:callframe framename (parameter = byref(variable){, parameter = byref(variable)})The following code is an example of this syntax:callframe myframe (number = byref(int_var),check_rec = ref_var,movies = byref(array_var));This example passes two variables by reference, number and movies,; and one variable by value, check_rec. Because the variable passed by valuereferences a 4GL object, changes made to the object in the child frame arevisible in the parent frame.Because the simple variable, number, was passed by reference, it also displayschanges to the parent that are made in the child. When you pass a simplevariable, such as int_var, by reference, any changes made to the parameter inthe called frame are reflected in the variable in the calling frame after thecalled frame closes. Passing simple variables by reference, therefore, gives youa way to pass multiple return values to a calling frame.102 <strong>Programming</strong> <strong>Guide</strong>

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

Saved successfully!

Ooh no, something went wrong!