PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • 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/iPadApple WatchUniversal Windows 10 AppWindows Mobile
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 in Parameter>)
For example:
Subscript 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 in 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
Notes:
  • 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 in Parameter>))
For example:
Subscript 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 in 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.
Notes:
  • The LOCAL keyword forces the copy of the element passed in 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
Versions 19 and later

Parameter corresponding to a project element

If your procedure is using 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.
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)
Note: 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. See Data Source variable for more details.
New in version 19

Parameter corresponding to a project element

If your procedure is using 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.
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)
Note: 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. See Data Source variable for more details.

Parameter corresponding to a project element

If your procedure is using 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.
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)
Note: 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. See Data Source variable for more details.
Special case
Versions 18 and later

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 in parameter to a procedure, 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
Notes:
  • 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 run time if the real parameter has no type).
Overloading WLanguage functions: Via the "list of values" parameters, you have the ability to overload the WLanguage functions that accept the lists of values, especially:
New in version 18

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 in parameter to a procedure, 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
Notes:
  • 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 run time if the real parameter has no type).
Overloading WLanguage functions: Via the "list of values" parameters, you have the ability to overload the WLanguage functions that accept the lists of values, especially:

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 in parameter to a procedure, 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
Notes:
  • 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 run time if the real parameter has no type).
Overloading WLanguage functions: Via the "list of values" parameters, you have the ability to overload the WLanguage functions that accept the lists of values, especially:
Minimum required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment