9. Using 3GL in Your Application : How You Can Use Exec 4GL Statements in 3GL Procedures : Example—Passing an Array to a 3GL Procedure : How You Can Call the 3GL Procedure
 
Share this page                  
How You Can Call the 3GL Procedure
When the frame calls the scale_y_array procedure, the frame passes an array (sales_array) whose data type is the saleschart_data user class. Two of the attributes in this class are significant to the 3GL procedure:
sales_value (float not null)
Contains the dollar sales for a given quarter of the fiscal year quarter (quarter)
y (integer not null)
Contains the Y-axis coordinate for each quarter to be displayed, after completion of the procedure
The frame also passes simple variables to the 3GL procedure. These variables are used to calculate the scale factor used to plot each point on the graph.
The line in the script that calls the scale_y_array procedure would be replaced by the following code if scale_y_array were an embedded SQL procedure:
/* Pass highest and lowest dollar amounts by
** reference to ensure portability when passing
** floating point parameters to C procedures. */
vmax = 1000.0;
vmin = 0.0;
callproc scale_y_array(byref(vmin), byref(vmax),
    ymax - (labelheight*2), 0, sales_array);
The frame passes several parameters:
vmax
Specifies the highest dollar amount to be displayed on the chart (represents the top of the chart)
vmin
Specifies the lowest dollar amount to be displayed on the chart (represents the bottom of the chart)
labelheight
Specifies the amount of space used by labels on the dynamically created chart; used to calculate the window position of the lowest Y point
sales_array
Specifies an array that contains the sales dollar amounts and contains the Y axis values
The vmax and vmin values are passed as variables, rather than directly as values, to ensure portability. For a discussion of passing floating point parameters to C procedures, see How You Can Pass Parameters to 3GL Procedures (see How You Can Pass Parameters to 3GL Procedures).