PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
This content has been translated automatically. Click here to view the French version.
  • Overview
  • Passing parameters to a window when it is opened
  • Returning a value when a window is closed
  • Running the test of a window 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/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Window with parameters
Overview
A window can:
  • Receive parameters when it is opened.
  • Return values when it is closed.
This window behaves like a procedure that may (or may not) return values.
This type of window can be useful in the following cases:
  • "calendar" windows (fix a default date when it is opened and return a selected date when it is closed),
  • search windows,
  • login windows returning the password typed, ...
This help page presents:
Passing parameters to a window when it is opened
To pass parameters to a window when it is opened:
1. Declare a procedure in the event "Global declarations" of the window. The name of this procedure is identical to the window name. The parameters of this procedure correspond to the parameters that must be passed to the window.
Caution: The procedure declaration (keyword PROCEDURE) must correspond to the first line of the event "Global declarations".
For example, the WIN_CALENDAR window is used to manage the date selection in a calendar. This window expects a parameter indicating the date to select.
// -- Déclarations globales de FEN_Calendrier
 
PROCÉDURE FEN_Calendrier(sDateSel)
//  sDateSel: date à sélectionner
This parameter can be handled from any event of the window (button, local procedures, etc.).
For example, in the event "Initializing" of WIN_Calendar:
// -- Initialisation de FEN_Calendrier
 
// Le champ SAI_ChampDate est un champ de saisie
// Il contient la valeur du paramètre sDateSel
SAI_ChampDate = sDateSel
2. Pass the parameter expected by the window when it is opened (Open up, OpenMobileWindow, OpenChild, OpenSister, MDIOpen). For example, the BTN_Calendar button is used to open the WIN_Calendar window. Today's date is passed as parameter when this window is opened.
// -- Code de clic du bouton BTN_Calendrier
 
// Ouverture de la fenêtre FEN_Calendrier
// Passage de la date du jour en paramètre
Open(FEN_Calendrier, Today())
Returning a value when a window is closed
To return a value when a window is closed:
  1. Use ReturnedValue in the processes that call Close.
    For example, in the WIN_Calendar window, the BTN_OK button and the BTN_CANCEL button close the window once the value to return was initialized:
    // -- Clic sur bouton BTN_OK (fenêtre FEN_Calendrier)
     
    // L'utilisateur a cliqué sur OK,
    // la date saisie dans le champ SAI_ChampDate est renvoyée
    MyWindow.ReturnedValue = SAI_ChampDate
    // Fermeture de la fenêtre
    Close()

    // -- Clic sur bouton BTN_ANNULER (fenêtre FEN_Calendrier)
     
    // L'utilisateur a cliqué sur BTN_ANNULER,
    // une chaîne vide est renvoyée
    MyWindow.ReturnedValue = ""
    // Fermeture de la fenêtre
    Close()

    It is also possible to use the Property ReturnedValue in the "Close" event of the window:
    // -- Code de fermeture de la fenêtre FEN_Calendrier
     
    // La date est saisie dans le champ SAI_ChampDate
    IF SAI_ChampDate = "" THEN
    // Aucune date saisie
    MyWindow.ReturnedValue = ""
    ELSE
    // Une date est saisie
    MyWindow.ReturnedValue = SAI_ChampDate
    END
  2. Retrieve in a variable the value returned by the window when it was closed. This variable contains the result of Open up.
    For example, the BTN_Calendar button is used to open the WIN_Calendar window. When opening this window (Open up), today's date is passed in parameter. The value returned by the window when it is closed corresponds to the result returned by the function Open up. This result is retrieved in the ResultDate variable:
    // -- Clic sur bouton BTN_Calendrier
    // Ouverture de la fenêtre FEN_Calendrier
    // DateRésultat est une variable chaîne contenant
    // la valeur renvoyée par la fenêtre FEN_Calendrier
    DateRésultat = Open(FEN_Calendrier, Today())
     
    // Analyse du résultat renvoyé par la fenêtre
    IF DateRésultat = "" THEN
    Info("Aucune date n'a été sélectionnée.")
    ELSE
    Info("Date sélectionnée: " + DateToString(DateRésultat, maskDateSystem))
    END

The code execution of BTN_Calendar is stopped until the WIN_Calendar window is closed.
Versions 18 and later
Universal Windows 10 App Special case: Value returned by a child window in a WINDEV Mobile application
In the mobile applications, the windows are opened by OpenMobileWindow (or OpenChild) instead of Open up.
You can get the value returned by a child window in the event "Closing a child window" of the window that opened it (the one that called OpenMobileWindow or OpenChild).
For example:
  • In the closing code of the child window, Close is used to return a parameter:
    Close("", MyParameter)
  • The name of the child window as well as the returned value can be retrieved in the event "Closing a child window" of the calling window, using the MyChildWindow keyword:
    // Fermeture d'une fenêtre fille
    NomFenêtreFille = MyChildWindow.Name
    ValeurFenêtreFille = MyChildWindow.ReturnedValue
New in version 18
Universal Windows 10 App Special case: Value returned by a child window in a WINDEV Mobile application
In the mobile applications, the windows are opened by OpenMobileWindow (or OpenChild) instead of Open up.
You can get the value returned by a child window in the event "Closing a child window" of the window that opened it (the one that called OpenMobileWindow or OpenChild).
For example:
  • In the closing code of the child window, Close is used to return a parameter:
    Close("", MyParameter)
  • The name of the child window as well as the returned value can be retrieved in the event "Closing a child window" of the calling window, using the MyChildWindow keyword:
    // Fermeture d'une fenêtre fille
    NomFenêtreFille = MyChildWindow.Name
    ValeurFenêtreFille = MyChildWindow.ReturnedValue
Universal Windows 10 App Special case: Value returned by a child window in a WINDEV Mobile application
In the mobile applications, the windows are opened by OpenMobileWindow (or OpenChild) instead of Open up.
You can get the value returned by a child window in the event "Closing a child window" of the window that opened it (the one that called OpenMobileWindow or OpenChild).
For example:
  • In the closing code of the child window, Close is used to return a parameter:
    Close("", MyParameter)
  • The name of the child window as well as the returned value can be retrieved in the event "Closing a child window" of the calling window, using the MyChildWindow keyword:
    // Fermeture d'une fenêtre fille
    NomFenêtreFille = MyChildWindow.Name
    ValeurFenêtreFille = MyChildWindow.ReturnedValue
Running the test of a window with parameters
To run the test of a window with parameters:
  1. Open the window with parameters in the window editor: on the "Home" tab, in the "General" group, click "Open".
  2. Click in the quick access buttons (or press F9). The following window is displayed:
    Testing a parameterized window
  3. Specify the value of the parameters that will be used to run the test of the window. To use the default value of the parameters, type the "*" character.
  4. Validate. The window is displayed according to the specified values.
Notes

Parameters passed by value

If the parameters passed to a window are modified in this window, these modifications will be taken into account in this window 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 as a parameter to the FEN_Calendar window.. The sSelDate parameter contains the value of the MyDate variable.
  3. The value of the sSelDate parameter is modified in the WIN_Calendar window (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 event "Global declarations" of WIN_Calendar:
// -- Déclarations globales de FEN_Calendrier
PROCÉDURE FEN_Calendrier(sDateSel = "20030101")
//  sDateSel: date à sélectionner

Scope of parameters

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