Tuto WEBDEV 25

466 Part 13: The WLanguage basics ▶ The amount IOT will be calculated via the code of the "Calculate" Button control. 1. Display the code of "Calculate" control ("Code" from the popup menu). 2. Write the following code in the "Click on BTN_Calculate (server code)" event: SWITCH COMBO_VAT..DisplayedValue // 5.5 % CASE 5.5 EDT_PriceIOT = EDT_PriceBT * 1.055 // 10 % CASE 10 EDT_PriceIOT = EDT_PriceBT * 1.1 // 20 % CASE 20 EDT_PriceIOT = EDT_PriceBT * 1.2 END This code calculates the amount IOT by using the value selected in the Combo Box control (returned by ..DisplayedValue ). 3. Run the page test ( among the quick access buttons). Give a price BT. Select the different values in the Combo Box control and click "CALCULATE". Our page operates properly now. However, instead of using a formula 3 times to calculate the price, a procedure can be used to perform this calculation . ▶ Close the test page to go back to the code editor. Creating and using a procedure ▶ To create the procedure for calculating the amount IOT: 1. Click the page background. 2. Display the events associated with the page (F2). 3.  In the code editor, on the "Code" pane, in the "Procedures" group, expand "New" and select "New local procedure (Server)". 4.  In the window that is displayed, type the name of local procedure ("Calc_IOT") and validate ("Add" button). 5.  The new procedure local to the page is automatically created and its code is displayed in the code editor.

RkJQdWJsaXNoZXIy NDQ0OA==