PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
  • Special cases
  • Named 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
The method for calling a procedure is the same, no matter whether it is a global procedure or a local procedure.
Reminder:
  • In WLanguage, there is no distinction between the procedures and the functions. The syntaxes for declaring and using procedures also apply to functions.
  • For a multi-syntax procedure, the call to the proper syntax is resolved at runtime. For more details, see Prototype overload.
Example
// Call to the Find procedure that returns a boolean
IF Find(Customer, CustNum, Number) THEN
Info("Customer number found")
ELSE
Info("Customer number not found")
END
Syntax

Calling a procedure that returns a parameter Hide the details

[<Returned value> = ] <Procedure name>([<Parameters>])
<Returned value>:
Value returned by the procedure (optional), only if the procedure returns a result.
The type of the return value of a procedure can be specified during its declaration. For more details, see Declaring a procedure.
<Procedure name>:
Name of the procedure to call.
<Parameters>:
Parameters passed to the procedure. Each parameter is separated by a comma.
WINDEV You have the ability to use named parameters. For more details, see "Named parameters".
For more details on how to declare the parameters of a procedure, see The parameters of a procedure.

Calling a procedure that returns several parameters Hide the details

(<Value 1>, ..., <Value N>) = <Procedure name>([<Parameters>])
<Value 1 to N>:
Values returned by the procedure.
The type of the return values of a procedure can be specified during its declaration. For more details, see Declaring a procedure.
<Procedure name>:
Name of the procedure to call.
<Parameters>:
Parameters passed to the procedure. Each parameter is separated by a comma.
WINDEV You have the ability to use named parameters. For more details, see "Named parameters".
For more details on how to declare the parameters of a procedure, see The parameters of a procedure.
Remarks

Special cases

  • To make your programs more readable, the PROCEDURE keyword can be replaced with the FUNCTION keyword.
  • If the procedure expects no parameter, you can also use the following syntax:
    [<Returned value> = ] <Procedure name>
  • To run a procedure of an opened window, use ExecuteProcess. Example:
    // Run the MyProc procedure found in WIN_MyWindow
    WinName is string = "WIN_MyWindow"
    ExecuteProcess(WinName + ".MyProc", trtProcedure)
WINDEV

Named parameters

If a procedure includes parameters with default values, you have the ability to call the procedure by naming its parameters. Two syntaxes are possible:
  • Single-line named parameters,
  • Multiline named parameters.
1. Single-line named parameters
The following syntax is used:
ProcedureName(< <name of parameter1> >: <value1>, < <name of parameter2> >: <value2>, ...)
Let's see the different operating rules via an example:
  • Code of the procedure:
    PROCEDURE MyProcedure(p1, p2, p3 = 0, p4 = 0, p5 = 0)
  • Call to the procedure by using named parameters:
    MyProcedure(<p1>:1, <p2>:2)
  • The unspecified optional parameters will be assigned with their default value.
    MyProcedure(<p1>:1, <p2>:2, <p4>:4)
  • The mandatory parameters can be passed without their name, by using the standard ordered parameters. The named parameters are necessarily found after the ordered parameters:
    MyProcedure(1, 2, <p4>:4)

    MyProcedure(1, <p4>:4, 2) // Triggers an error
  • All the mandatory parameters must be specified otherwise a compilation error will occur.
    MyProcedure(<p1>:1) // error: p2 missing

    MyProcedure(<p1>:1, <p4>:4)// error: p2 missing
  • Each parameter must be specified once only otherwise a compilation error will occur.
    MyProcedure(<p2>:2, <p1>:1, <p2>:2) // error: p2 twice
  • The parameters can be specified in any order: the values of parameters are evaluated in the standard writing order (from left to right).
    MyProcedure(f1(), f2(), <p5>:f3(), <p4>:f4()) // Execution order: f1, f2, f3, f4
The rules for passing parameters are identical to the ones applied during a standard call. For more details, see Passing parameters.
2. Multiline named parameters
The following syntax is used:
// Define the parameters
ProcedureName.<Name of parameter 1> = <Value 1>
...
ProcedureName.<Name of parameter N> = <Value N>
// Call the procedure
ProcedureName()
This syntax is available:
  • for the global procedures.
  • for the local procedures called from the element that owns the procedure.
  • for the methods called from a method of the class or derived class.
Example:
  • Code of the procedure:
    PROCEDURE MyProcedure(p1, p2, p3 = 0, p4 = 0, p5 = 0)
  • Call code:
    // Define the parameters
    MyProcedure.p1 = 1
    MyProcedure.p2 = 2
    // Call the procedure
    MyProcedure()
Remarks:
  • The parameters of the procedure are limited to the current process. Therefore, the call and the assignments must be found in the same process. A compilation error occurs if parameters are specified and if no call to the procedure is detected in the process.
  • No check is performed regarding the presence of mandatory parameters. An error may occur at runtime if a mandatory parameter was not specified.
  • The parameters are reinitialized during the call so that no parameter can be re-used by mistake ; therefore, two calls cannot be performed with the same parameters.
  • Caution: In this case, passing parameters is performed by value (and not by variable).
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment