PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

  • Passing parameters to a page when it is opened
  • To pass parameters to a page when it is opened:
  • Running the test of a page with parameters
  • Notes
  • Parameters passed by value
  • Giving a default value to the parameter in the declaration
  • Scope of parameters
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
Page with parameters
Passing parameters to a page when it is opened

To pass parameters to a page when it is opened:

1. Declare a procedure in the "Global Declarations" process of the page. The name of this procedure and the page name must be identical. The parameters of this procedure correspond to the parameters that must be passed to the page.
Caution: The declaration of the procedure (PROCEDURE keyword) must correspond to the first line of the "Declaration process of global variables".
For example, the PAGE_CALENDAR page is used to manage the selection of a date in a calendar. This page expects a parameter indicating the date to select.
// -- Declaration of global variables of PAGE_CALENDAR --

PROCÉDURE PAGE_Calendar(sSelDate)
// sSelDate: date specifying the date to select.
This parameter can be handled from any process of the page (button, local procedures, ...).
For example, in the "Initialization" process of the PAGE_CALENDAR page:
// -- Initialization of PAGE_CALENDAR --

// EDT_DateControl is an edit control
// It contains the value of the sSelDate parameter
EDT_DateControl = sSelDate
2. Pass the parameter expected by the page when it is opened (PageDisplay, PageUse, ...). For example, the BTN_CALENDAR button is used to open the PAGE_CALENDAR page. When this page is opened, today's date is passed in parameter.
// -- Click code of BTN_CALENDAR button --

// Open the PAGE_CALENDAR page
// Today's date is passed in parameter
PageDisplay(PAGE_CALENDAR, Today())
Running the test of a page with parameters
To run the test of a page with parameters:
  1. Open the page with parameters in the page editor.
  2. Click (or press [F9]). The following window is displayed:
  3. Specify the value of the parameters that will be used to run the test of the page. To use the default value of the parameters, type the "*" character.
  4. Validate. The page is displayed according to the specified values.
Notes

Parameters passed by value

If the parameters passed to a page are modified in this page, these modifications will be taken into account in this page only. The value of these parameters is not modified in the calling process.
For example:
  1. The MyDate variable is declared in the code of the BTN_CALENDAR button. This variable contains today's date (for example: MyDate = Today()).
  2. This variable is passed in parameter to the PAGE_CALENDAR page. The sSelDate parameter contains the value of the MyDate variable.
  3. The value of the sSelDate parameter is modified in the PAGE_CALENDAR page (for example: sSelDate = "20020701")
  4. The value of the MyDate variable is not modified.

Giving a default value to the parameter in the declaration

A default value can be given to the parameters when declaring the parameters.
For example, to give a default value in the previous example, enter the following code in the "Declaration process of global variables" of the PAGE_CALENDAR page:
// -- Declaration of global variables of PAGE_CALENDAR --

PROCÉDURE PAGE_Calendar(sSelDate = 20030101)
// sSelDate: date specifying the date to select.

Scope of parameters

The parameters passed to a page are global to all the processes of this page (initialization, code of a button, code of a local procedure, ...).
See also
Minimum required version
  • Version 9
Comments
Click [Add] to post a comment