Tuto WINDEV 25

70 Part 2: The WLanguage basics Remark When typing conditional statements in the code editor, the different possible syntaxes are proposed in a list by the code editor. If you select one of these syntaxes, the statement structure is automatically inserted into the code editor. Simply enter the WLanguage code corresponding to each part of the statement. 8. Close the code window (click X at the top right corner of code editor). ▶ Let’s now create a Button control to move the image until it reaches the right border of the window. To do so, we will be using the WHILE statement of WLanguage. 1. On the "Creation" pane, in the "Usual controls" group, click . 2. Click the location where the control will be created (for example, to the right of the "FOR statement" control). 3. Click the control that was just created. The text displayed in the control becomes editable. Type the caption: "WHILE statement". 4. Press Enter to validate the input. 5. Adapt the control size. 6. Display the events associated with the control (F2). 7. Write the following code in the "Click" WLanguage event: // Moves the image horizontally until you reach the window side WHILE IMG_NoName1..X < WinInWidth() - IMG_NoName1..Width IMG_NoName1..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 the width of the window minus the width of the Image control. 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. 8. 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 window. 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 control will be created (for example, to the right of the "WHILE statement" 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. Adapt the control size. 6. Display the WLanguage events associated with the control (F2).

RkJQdWJsaXNoZXIy NDQ0OA==