ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage syntax / WLanguage procedures / Procedure parameters
  • Overview
  • Passing parameters by reference
  • Default operating mode
  • Passing a control, a window or a report
  • Passing parameters by value
  • Overview
  • Solution 1: Using double brackets
  • Solution 2: Using "local" parameters in the procedure
  • Parameter corresponding to a project element
  • Special case
  • Passing a list of values
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
Overview
The parameters can be passed to a procedure:
Passing parameters by reference

Default operating mode

By default, when calling a procedure, the parameters are passed by reference (by variable or by address). If the parameter is modified in the procedure, the process calling the procedure will retrieve the parameter with its modified value.
To pass a parameter by variable to a procedure, use the following syntax:
<Procedure name>(<Name of variable passed as parameter>)
For example:
Index is int = 1
// Before the call to the procedure, Subscript is set to 1
AddOne(Subscript)
// After the call to the procedure, Subscript is set to 2
// -- Declare the procedure
PROCEDURE AddOne(Counter)
Counter += 1

Passing a control, a window or a report

During the call to a procedure, the parameters can be a control, a window or a report. This object (control, window or report) is handled like any "standard" object.
To pass an element as parameter to a procedure, use the following syntax:
<Procedure name>(<Element name>)
For example:
// Call the ControlNotVisible procedure
ControlNotVisible(ControlAddress)
// -- Declare the procedure
PROCEDURE ControlNotVisible(ControlAddress)
ControlAddress..Visible = False
Remarks:
  • The MySelf keyword is used to handle the current control.
  • The MyWindow keyword is used to handle the current window.
  • The MyReport keyword is used to handle the current report.
Passing parameters by value

Overview

During the call to a procedure, the parameters can be passed by value. If the parameter is modified in the procedure, the process calling the procedure will retrieve the parameter with its unmodified value.
Two methods can be used to pass the parameters by value:

Solution 1: Using double brackets

To pass a parameter by value to a procedure, use the following syntax:
<Procedure name>((<Name of variable passed as parameter>))
For example:
Index is int = 1
// Before the call to the procedure, Subscript is set to 1
AddOne((Subscript))
// After the call to the procedure, Subscript is still set to 1
// -- Declare the procedure
PROCEDURE AddOne(Counter)
Counter += 1

Solution 2: Using "local" parameters in the procedure

When declaring a procedure, the variables passed as parameter can become local to this procedure. To do so, the local parameter must be preceded by the LOCAL keyword. For example:
PROCEDURE MyProc(LOCAL Subscript, LOCAL Counter, Number)
If this parameter is modified in the procedure, the process calling the procedure will retrieve the parameter with its unmodified value.
Remarks:
  • The LOCAL keyword forces the copy of the element passed as parameter in the following cases:
    • instance of class or instance of array passed to an untyped parameter.
      Example:
      Procedure MyProcedure(LOCAL Parameter)
    • instance of class passed to a typed parameter.
      Example:
      Procedure MyProcedure(LOCAL Parameter is CClass)
  • PCS_SANS_TRADUCTION_US

Parameter corresponding to a project element

If your procedure uses project elements, until version 19, the name of the element had to be enclosed in quotes during the call to the procedure. For example:
MyProcedure("WIN_Example")
From version 19, you can pass the name of the element without quotes and you can benefit from the completion on the parameter during the input.
WINDEVWINDEV Mobile Case of windows
All you have to do is use the <window name> extension attribute. The following syntax must be used:
PROCEDURE WindowName(WindowName is string <window name>)
Example:
// Declare the procedure
PROCEDURE InputControl(sWindowName is string <window name>)

let i = 1
either ResControl = EnumControl(sWindowName, i)
WHILE ResControl <> ""
i++
Trace ("Processing control " +ResControl+" from the window " + sWindowName)
ResControl = EnumControl(sWindowName, i)
END
In this example, during the call to the procedure, the sWindowName parameter contains the name of the window. The completion will propose all the windows found in the project.
The calls to the procedure may correspond to the following syntaxes:
  • InputControl(WindowName)
  • InputControl("WindowName")
  • InputControl(Name of string variable containing the name of the window)
WEBDEV - Server code Page case
All you have to do is use the <page name> extension attribute. The following syntax must be used:
PROCEDURE ProcedureName(PageName is string <page name>)
Example:
// Declare the procedure
PROCEDURE InputControl(sPageName is string <page name>)
In this example, during the call to the procedure, the sPageName parameter contains the name of the page. The completion will propose all the pages found in the project.
The calls to the procedure may correspond to the following syntaxes:
  • InputControl(PageName)
  • InputControl("PageName")
  • InputControl(Name of string variable containing the name of the page)
Report case
All you have to do is use the <report name> extension attribute. The following syntax must be used:
PROCEDURE ProcedureName(ReportName is string <report name>)
Example:
// Declare the procedure
PROCEDURE Checkdata(sReportname is string <report name>)
In this example, during the calling to the procedure, the sReportName parameter contains the name of the report. The completion will propose all the reports found in the project.
The calls to the procedure may correspond to the following syntaxes:
  • InputControl(ReportName)
  • InputControl("ReportName")
  • InputControl(Name of string variable containing the name of the report)
Case of data sources
The following syntax must be used:
PROCEDURE ProcedureName(FileName is Data Source)
Example:
// Declare the procedure
PROCEDURE CheckData(sFileName is Data Source)
In this example, during the call to the procedure, the sFilewName parameter contains the name of a data source. The completion will propose all the data sources (files, queries, Data Source variables) found in the project.
The calls to the procedure may correspond to the following syntaxes:
  • CheckData(File)
  • CheckData(Query)
  • CheckData("File")
  • CheckData("Query")
  • CheckData(Name of string variable containing the name of the file or query)
  • CheckData(Name of data source variable)
Remark: To associate the data source with an existing data file (or query), all you have to do is add a specific extension attribute. In this case, the automatic completion will allow you to access the items directly. For more details, see Data Source variable.
Special case

Passing a list of values

During the call to a procedure, the parameters can be a list of values ("[1,2,3]" for example).
To pass a list of values to a procedure as parameter, use the following syntax:
<Procedure name>(<List of values>)
For example:
// Call the procedure
MyProcedure([1,2,3])
// -- Declare the procedure
PROCEDURE MyProcedure(Values)
MyArray is array of int = Values
Remarks:
  • If the procedure parameter has no type, the list of values is passed to the procedure directly. As the lists of values cannot be handled directly, this parameter can only be used in the features that accept the lists of values:
    • call to a WLanguage function that authorizes the lists of values (HFilter, HReadSeek, ...).
    • assignment in a structured variable (array, class, structure, ...).
    • call to a user procedure that allows a list of values.
  • If the parameter of the procedure is an array, an array is automatically allocated and filled with the values found in the list of values.
  • If the parameter of the procedure has another type, a compilation error will occur (or a WLanguage error will occur at runtime if the real parameter has no type).
Overriding WLanguage functions: You can override WLanguage functions that accept the lists of values via the "list of values" parameters, especially:
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 07/03/2023

Send a report | Local help