Tuto WEBDEV 25

456 Part 13: The WLanguage basics 8. Enter the following code in the "Click (Browser)" event: WHILE IMG_Animal..X < 1200 IMG_Animal..X++ END This code is used to modify the X coordinate of Image control ( ..X ) until a condition is true. In our case, this condition is as follows: the position of the Image control ( ..X ) must correspond to 1200. Tip When a code line is too long to be displayed in the window of code editor, you have the ability to cut it in 2 by using a carriage return. 9. Close the code window (click X at the top right corner of code editor). ▶ Now let’s create a last Button control to move the Image control until it reaches the left border of the page. To do so, we will be using the LOOP statement of WLanguage. 1. On the "Creation" pane, in the "Usual controls" group, click . 2. Click the location where the button will be created (for example, on the right of WHILE Button control). 3. Click the control that was just created. The text displayed in the control becomes editable. Type the caption: "LOOP statement". 4. Press Enter to validate the input. 5. Display the description window of control (press Alt + Enter). 6.  In the "General" tab, in the "Button action" area: • for the "Type" option, select "Run the browser click code only". • for the "During the action" option, select "Do not send anything to the server". 7. Validate the description window of control. 8. Display the events associated with the control (F2). 9. Enter the following code in the "Click (browser)" event: // Moves the image to the left LOOP IMG_Animal..X-- IF IMG_Animal..X <= 0 THEN BREAK END This WLanguage code allows you to modify the X coordinate of the Image control ( ..X property). At each turn, a condition is checked. If this condition is true, the program exits from the loop. In our case, the condition is as follows: • the position of the Image control is 0,

RkJQdWJsaXNoZXIy NDQ0OA==