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 You Can Use Exec 4GL Statements in 3GL ProceduresThe procedure uses the inquire_4gl statement to determine the number ofrows in the array. It then uses this number as the maximum iteration of awhile loop, for example:/* Find out how many rows in the array */exec 4gl inquire_4gl (:nrows = lastrow(:array_handle));The while loop gets a handle for each row in the array. This loop uses thehandle to get the value in that row's sales_value attribute. The value obtainedis subtracted from the highest dollar value and multiplied by the scale value todetermine the Y value for that row. Finally, the loop sets the value of the yattribute in the appropriate row of sales_array.The following code shows how the while loop processes each row in the arrayto determine and set its Y value:/* Loop through sales values in the array and** put scaled values into y. */i = 0;while (i++ < nrows){exec 4gl getrow :array_handle :i(:row_handle = ROW);exec 4gl get attribute :row_handle(:value = sales_value);value = scale_factor * (*high_value - value);exec 4gl set attribute :row_handle (y = :value);}The following statement, the last in the 3GL procedure, returns control to thecalling frame:return;Example—Sending a User Event from 3GL to 4GLA 3GL procedure can send user events to 4GL frames and procedures by usingexec 4GL statements. However, because the user event is not received by the4GL until control returns from the 3GL, user events are not as common a formof communication between 3GL and 4GL as they are between concurrentlyopen 4GL frames.Sending user events from 3GL to 4GL is useful when the 4GL calls the 3GLregularly to communicate with the outside world. For example, an applicationmight use a ghost frame to call a 3GL procedure every minute by sending itselfdelayed user events. The 3GL procedure monitors outside conditions and sendsthe ghost frame a user event when it encounters significant conditions.Because the 3GL can monitor several conditions, it can send multiple userevents to the ghost frame.Using 3GL in Your Application 303

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

Saved successfully!

Ooh no, something went wrong!