Tuto WEBDEV 25
Part 13: The WLanguage basics 461 The code used to call the procedure is as follows: res is int Res = Multiplication(10, 50) // Res is equal to 500 How to use the parameters? By default, passing parameters in WLanguage is performed by reference (or by address). The parameter in the procedure represents (references) the variable passed during the call. Therefore, when a procedure statement modifies the parameter value, the value of the variable corresponding to this parameter is modified. Example: • The procedure code is as follows: PROCEDURE Test_address(P1) P1 = P1 * 2 • The code used to call the procedure is as follows: T is int T = 12 // T is equal to 12 before the call Test_address(T) // T is equal to 24 after the call To avoid modifying the value of the variable corresponding to the parameter, the parameters must be passed by value . Passing parameters by value allows you to handle a copy of parameter value. If the procedure code modifies the variable value, the value of the variable corresponding to the parameter is not modified. To force a parameter to be passed by value to a procedure, the LOCAL keyword must be used in front of the parameter name in the procedure declaration. This keyword indicates that the following parameter will not be modified by the procedure. Example: • The procedure code is as follows: PROCEDURE Test_value(LOCAL P1) // Local indicates that the parameter will be passed by value P1 = P1 * 2 • The code used to call the procedure is as follows: T is int T = 12 // T is equal to 12 Test_value(T) // T does not change Remark In the same procedure, some parameters can be passed by reference while other parameters can be passed by value. All you have to do is used the LOCAL keyword in front of each parameter passed by value.
Made with FlippingBook
RkJQdWJsaXNoZXIy NDQ0OA==