PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Special cases
  • Named parameters
  • Calling a global WLanguage browser procedure from a global Javascript procedure (found in the same set of procedures)
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
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 the procedures also apply to the functions.
  • Versions 16 and later
    For a multi-syntax procedure, the call to the proper syntax is resolved at run time. See Prototype overload for more details.
    New in version 16
    For a multi-syntax procedure, the call to the proper syntax is resolved at run time. See Prototype overload for more details.
    For a multi-syntax procedure, the call to the proper syntax is resolved at run time. See Prototype overload for more details.
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.
Versions 18 and later
The type of the return value of a procedure can be specified during its declaration. See Declaring a procedure for more details.
New in version 18
The type of the return value of a procedure can be specified during its declaration. See Declaring a procedure for more details.
The type of the return value of a procedure can be specified during its declaration. See Declaring a procedure for more details.
<Procedure name>:
Name of the procedure to call.
<Parameters>:
Parameters passed to the procedure. Each parameter is separated by a comma.
Versions 20 and later
WEBDEV - Server code You have the ability to use named parameters. See "Named parameters" for more details.
New in version 20
WEBDEV - Server code You have the ability to use named parameters. See "Named parameters" for more details.
WEBDEV - Server code You have the ability to use named parameters. See "Named parameters" for more details.
See The parameters of a procedure for more details.
Versions 19 and later

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. See Declaring a procedure for more details.
<Procedure name>:
Name of the procedure to call.
<Parameters>:
Parameters passed to the procedure. Each parameter is separated by a comma.
Versions 20 and later
WEBDEV - Server code You have the ability to use named parameters. See "Named parameters" for more details.
New in version 20
WEBDEV - Server code You have the ability to use named parameters. See "Named parameters" for more details.
WEBDEV - Server code You have the ability to use named parameters. See "Named parameters" for more details.
See The parameters of a procedure for more details.
New in version 19

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. See Declaring a procedure for more details.
<Procedure name>:
Name of the procedure to call.
<Parameters>:
Parameters passed to the procedure. Each parameter is separated by a comma.
Versions 20 and later
WEBDEV - Server code You have the ability to use named parameters. See "Named parameters" for more details.
New in version 20
WEBDEV - Server code You have the ability to use named parameters. See "Named parameters" for more details.
WEBDEV - Server code You have the ability to use named parameters. See "Named parameters" for more details.
See The parameters of a procedure for more details.

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. See Declaring a procedure for more details.
<Procedure name>:
Name of the procedure to call.
<Parameters>:
Parameters passed to the procedure. Each parameter is separated by a comma.
Versions 20 and later
WEBDEV - Server code You have the ability to use named parameters. See "Named parameters" for more details.
New in version 20
WEBDEV - Server code You have the ability to use named parameters. See "Named parameters" for more details.
WEBDEV - Server code You have the ability to use named parameters. See "Named parameters" for more details.
See The parameters of a procedure for more details.
Remarks

Special cases

  • To make your programs more readable, the PROCEDURE keyword can be replaced by 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, all you have to do is use ExecuteProcess. Example:
    // Run the MyProc procedure found in WIN_MyWindow
    WinName is string = "WIN_MyWindow"
    ExecuteProcess(WinName + ".MyProc", trtProcedure)
Versions 20 and later
WEBDEV - Server code

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. See Passing parameters for more details.
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
    ProcedureName.p2 = 2
    // Call the procedure
    MyProcedure()
Notes:
  • 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 run time 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).
New in version 20
WEBDEV - Server code

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. See Passing parameters for more details.
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
    ProcedureName.p2 = 2
    // Call the procedure
    MyProcedure()
Notes:
  • 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 run time 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).
WEBDEV - Server code

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. See Passing parameters for more details.
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
    ProcedureName.p2 = 2
    // Call the procedure
    MyProcedure()
Notes:
  • 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 run time 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).
WEBDEV - Browser code

Calling a global WLanguage browser procedure from a global Javascript procedure (found in the same set of procedures)

To call a WLanguage browser procedure from a JavaScript procedure, the name of the WLanguage procedure must be prefixed by the name of the set of procedures. The procedure name and the function name must be separated by an underscore (_) and not by a dot.
The name of the set of procedures used in the Javascript procedure:
  • must contain no accented character,
  • must be written in uppercase characters,
  • without punctuation,
  • without space characters.
For example: To call the WLanguage procedure named "MySet to test.UnitTest", you must write "MYSETTOTEST_UnitTest" in the Javascript procedure.
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment