ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage syntax / WLanguage procedures
  • Special cases
  • Named parameters
  • Calling a global WLanguage browser procedure from a global JavaScript procedure (found in the same set of procedures)
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
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
// Appel de la procédure Trouve qui retourne un booléen
IF Trouve(Client, NumCli, Numéro) THEN
Info("Numéro de client trouvé")
ELSE
Info("Numéro de client inexistant")
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 Registering an Procedure.
<Procedure name>:
Name of the procedure to call.
<Parameters>:
Parameters passed to the procedure. Each parameter is separated by a comma.
WINDEViPhone/iPad If the parameters to be passed to Procedure are stored in a array , it is possible to use the function TableauVersParamètres f002300 to obtain the parameters in the format expected by Procedure.
WINDEVWEBDEV - Server codeiPhone/iPadIOS WidgetApple WatchMac Catalyst 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 Registering an Procedure.
<Procedure name>:
Name of the procedure to call.
<Parameters>:
Parameters passed to the procedure. Each parameter is separated by a comma.
WINDEViPhone/iPad If the parameters to be passed to Procedure are stored in a array , it is possible to use the function TableauVersParamètres f002300 to obtain the parameters in the format expected by Procedure.
WINDEVWEBDEV - Server codeiPhone/iPadIOS WidgetApple WatchMac Catalyst 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:
    [<Valeur retournée> = ] <Nom de la procédure>
  • To run a procedure of an opened window, use ExecuteProcess. Example:
    // Exécution de la procédure MaProc contenue dans la fenêtre FEN_MaFenêtre
    NomFen is string = "FEN_MaFenêtre"
    ExecuteProcess(NomFen + ".MaProc", trtProcédure)
WINDEVWEBDEV - Server codeiPhone/iPadIOS WidgetApple WatchMac Catalyst

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:
NomProcédure(< <nom du paramètre1> >: <valeur1>, < <nom du paramètre2> >: <valeur2>, ...)
Let's see the different operating rules via an example:
  • Procedure Code :
    PROCÉDURE MaProcédure(p1, p2, p3 = 0, p4 = 0, p5 = 0)
  • Call to the procedure by using named parameters:
    MaProcédure(<p1>:1, <p2>:2)
  • The unspecified optional parameters will be assigned with their default value.
    MaProcédure(<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:
    MaProcédure(1, 2, <p4>:4)

    MaProcédure(1, <p4>:4, 2) // Provoque une erreur
  • All the mandatory parameters must be specified otherwise a compilation error will occur.
    MaProcédure(<p1>:1) // erreur: p2 manquant

    MaProcédure(<p1>:1, <p4>:4)// erreur: p2 manquant
  • Each parameter must be specified once only otherwise a compilation error will occur.
    MaProcédure(<p2>:2, <p1>:1, <p2>:2) //erreur: p2 en double
  • The parameters can be specified in any order: the values of parameters are evaluated in the standard writing order (from left to right).
    MaProcédure(f1(), f2(), <p5>:f3(), <p4>:f4()) // Ordre d'exécution: f1, f2, f3, f4
The rules for passing parameters are identical to the ones applied during a standard call. For more details, see Passage of parameters.
2. Multiline named parameters
The following syntax is used:
// Définition des paramètres
NomProcédure.<Nom du paramètre 1> = <Valeur 1>
...
NomProcédure.<Nom du paramètre N> = <Valeur N>
// Appel de la procédure
NomProcédure()
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:
  • Procedure Code :
    PROCÉDURE MaProcédure(p1, p2, p3 = 0, p4 = 0, p5 = 0)
  • Call code:
    // Définition des paramètres
    MaProcédure.p1 = 1
    MaProcédure.p2 = 2
    // Appel de la procédure
    MaProcédure()
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).
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

Last update: 09/19/2024

Send a report | Local help