runWithStatus

runWithStatus(dialogForm:   Form;
              dialogMethod: Method;
              status:       Integer output;
              outputCount:  Integer output);

The runWithStatus method of the JadeReportWriterReport class runs the current report, using the parameter values specified in the set methods, displaying the progress dialog form specified in the dialogForm parameter, which is refreshed by the method specified in the dialogMethod parameter.

The dialogForm and dialogMethod parameters are optional. If you set the dialogForm parameter to null, the value of the dialogMethod parameter is ignored and the report is run in the same way as the JadeReportWriterReport class run method, but the values of the status and outputCount parameters are returned.

If you specify a dialogForm and dialogMethod parameter value, the method specified in the dialogMethod parameter must be defined on the form instance specified in the dialogForm parameter and it must have two String parameters. When the JADE Report Writer calls the specified method, the first parameter is a descriptive string of the current phase of the report process. When called in the query phase, the second parameter contains the number of database objects that have been read. When called during the printing phase, the second parameter contains the number of pages that have been printed or records that have been extracted. In the printing phase, the page number is returned every 20 pages to the method specified by the dialogMethod parameter, and the standard JADE print progress dialog is not shown.

Any value returned from the method specified by the dialogMethod parameter is cast as a Boolean. If the resulting value is false, the report continues to run. If the value is true, the report is stopped. This enables you to cancel a report.

If the method specified in the dialogMethod parameter is not defined for the Form class specified in the dialogForm parameter or it does not contain two String parameters, the specified method is not called.

When the report is run, a call is made to the Object class jadeReportWriterCheck method for each object and the object is reported only if the jadeReportWriterCheck method returns true.

Call the runWithStatus method as the last method that you call following the completion of the setting up of your report requirements. (See also the JadeReportWriterReport class run method, which runs the current report without a progress dialog and with no return values.)

When the report has been run, the status parameter contains zero (0) if the report ran successfully, minus 1 (-1) if the report run was cancelled, or the appropriate exception code (for example, error code 15017, or Print_Not_Available, if the specified printer does not match the available printers).

The outputCount parameter contains the page count if the report was output to a printer, or it contains the record count if the report was extracted to a file.

The following example shows the use of the runWithStatus method.

btnRun_click(btn: Button input) updating;
vars
    dialogForm          : MyDialogForm;
    dialogMethod        : Method;
    jrep                : JadeReportWriterReport;
    strName, strProfile : String;
    intOrient, intIndex : Integer;
    stat, count         : Integer;
begin
    if lstReports.listIndex = -1 then
        return;
    endif;
    create dialogForm transient;
    dialogMethod := dialogForm.class.getMethod("pageUpdate ");
    strName      := lstReports.itemText[lstReports.listIndex];
    jrep         := myJWRM.getReport(strName);
    if jrep = null then
        return;
    endif;
    if chkOrientation.value then
        intOrient := 2;          // landscape
    else
        intOrient := 1;          // portrait
    endif;
    intIndex := lstProfiles.listIndex;
    if lstProfiles.listIndex = -1 and lstProfiles.listCount > 0 then
        intIndex   := 1;
    endif;
    intIndex := lstProfiles.listIndex;
    if lstProfiles.listIndex = -1 and lstProfiles.listCount > 0 then
        intIndex   := 1;
    endif;
    if intIndex > 0 then
        strProfile := lstProfiles.itemText[intIndex];
        jrep.setProfile(strProfile);
    endif;
    jrep.setPreviewOptions(chkPreview.value, true, false, true, "");
    jrep.setPageOptions(Print_A4, intOrient, 1, 0, 0, 10, 10, 0, true, 1);
    jrep.runWithStatus(dialogForm, dialogMethod, stat, count);
epilog
    delete jrep;
    if dialogForm <> null then
        dialogForm.unloadForm;
    endif;
end;