Tuto WEBDEV 25
462 Part 13: The WLanguage basics Mandatory or optional parameters? The parameters received in the procedure can be mandatory or optional parameters. A mandatory parameter must be filled during the call to the procedure while an optional parameter can be omitted: in this case, it will take the default value defined when declaring the procedure parameters. Remark When declaring a procedure, the optional parameters are the last parameters (they are always specified after all mandatory parameters). In the following example, the Multiplication procedure is using an optional parameter, Nb2. This optional parameter is indicated after the mandatory parameters, by specifying its default value. In this example, the default value of optional parameter is set to 10. PROCEDURE Multiplication(Nb1 is int, Nb2 is int=10) MyResult is int MyResult = Nb1 * Nb2 RESULT MyResult The code used to call the procedure is as follows: res is int res = Multiplication(6) // Res is equal to 60 In this example, the second parameter was not specified. Therefore, its default value will be used. Procedure result The procedures can return one or more results. The result can be typecasted. The RESULT keyword must be used to return a value. See the online help for more details (keyword: Result). Practical example: Using a procedure In a new page, we are now going to: • Create two numeric edit controls containing the value BT and the value IOT. • Create a Combo Box control used to choose the VAT rate. • Create a Button control used to calculate and display the value IOT of the amount BT entered. The calculation result will be displayed in the "Price IOT" control.
Made with FlippingBook
RkJQdWJsaXNoZXIy NDQ0OA==