PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Overview
  • Creating a report with parameters
  • Overview
  • Example
  • Printing a report with parameters
  • Example
  • Tip
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Overview
When printing a report, you have the ability to pass parameters to this report. The report is called "Report with parameters".
For example, your report corresponds to a mailshot sent to all the customers. The text of the mailshot is entered in a control before running this report. This text corresponds to a parameter expected by the report.
Report with Parameters
Versions 18 and later
iPhone/iPad This feature is now available for the iPhone/iPad applications.
New in version 18
iPhone/iPad This feature is now available for the iPhone/iPad applications.
iPhone/iPad This feature is now available for the iPhone/iPad applications.
Creating a report with parameters

Overview

The creation of a report with parameters is performed in several steps:
  1. Creating a report.
  2. Modifying this report to support the parameters:
    • Retrieving the parameters in the "Opening" code of the report via the following syntax:
      PROCEDURE <ReportName>(<NameParam1>, ...
      <NameParam2>= "<DefaultValueParam2>", ...
      ...
      <NameParamN> = "<DefaultValueParamN>")

      Reminder: Some of the parameters passed to a procedure can be optional parameters. When declaring the procedure, the optional parameters must be described in last position (on the right), with a default value preceded by the "=" sign. See Parameter of a procedure for more details.
    • Using these parameters in the report controls.
  3. Modifying (if necessary) the application in order to specify the different parameters.
  4. Printing the report while passing parameters. See Printing a report with parameters for more details.

Example

The program required to create a report with parameters is illustrated by the following example:
  • The "RPT_ParamReport" report corresponds to a mailing sent to the customers.
  • This report expects in parameter the text of the mailing entered in the "EDT_MailingText" edit control.
Implementation:
  1. Create the "RPT_ParamReport" report ("File .. New .. Mailing report"). This report is linked to the "Customer" file of your analysis. See The reports for more details.Create the "RPT_ParamReport" report:
    • Click New among the quick access buttons.
    • Click "Report" in the wheel that is displayed. The window for creating a new element is displayed: click "Report" then "Report".
    • The wizard for report creation starts.
    • In the wizard, select "Mailshot" and validate.
      This report is linked to the "Customer" file of your analysis. See The reports for more details.
  2. Customize this report.
  3. Enter the following code in the "Opening" process of the "RPT_ParamReport" report:
    // Retrieve the parameter passed to the report and
    // pass a default parameter for the report test
    PROCEDURE RPT_ParamReport(sText = "Default value")
  4. In the Body block of this report, add the "STC_MailingText" static control used to display the text of the mailing.
  5. In the "Before printing" process of "STC_MailingText" control, type the following code:
    // Retrieve the mailing text
    STC_MailingText = sText
  6. In an application window, add:
    • the "EDT_MailingText" edit control allowing the user to type the text of the mailing.
    • the "BTN_Print" button used to print the report.
Printing a report with parameters
To print a report with parameters, you must:
  1. Configure the destination of the report print with iPreview (print preview, print in an HTML file, ...).
  2. Specify the following parameters with iPrintReport:
    • the name of the report to print.
    • the parameters.
Notes:
  • If the report is based on a HFSQL view, the name of this HFSQL view must be specified in iPrintReport, before the parameters. See Report on HFSQL view for more details.
  • If the report is based on a memory zone, the name of this memory zone must be specified in iPrintReport, before the parameters. See Report on memory zone for more details.
  • If the report is bounded, the maximum and minimum values of the bounds must be specified in iPrintReport, before the parameters. See Bounded report for more details.
Note: From version 19, HFSQL is the new name of HyperFileSQL.

Example

The "RPT_ParamReport" report corresponds to a mailing sent to the customers. This report expects in parameter the text of the mailing entered in the "EDT_MailingText" edit control.
The "RPT_ParamReport" report is printed during a click on the "BTN_Print" button.
In this example, the code of the "BTN_Print" button is as follows:
// Open the preview window
iPreview()
// Print the report while passing parameters
iPrintReport(RPT_ParamReport, EDT_MailingText)
Tip
To run the test of a report with parameters from the report editor, a default value should be given to the parameters in the parameter declaration.
For example, to run the test of the report found in the previous example, enter the following code in the "Opening" process of the "RPT_ParamReport" report:
// Retrieve the parameter passed to the report and
// pass a default parameter for the report test
PROCEDURE RPT_ParamReport(sText = "Default value")
Minimum required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment