tailieunhanh - Loop Exceptions

Vòng ngoại lệ Nói chung, một vòng lặp tiếp tục thực hiện lặp lại cho đến khi tình trạng của nó là không còn đúng nữa. Bạn sử dụng hai hành động để thay đổi hành vi này: tiếp tục và phá vỡ. Với việc tiếp tục hành động, bạn có thể ngừng lặp đi lặp lại hiện tại (có nghĩa là, không có hành động hơn nữa trong sự lặp lại mà sẽ được thực hiện) và chuyển thẳng đến phiên bản tiếp theo trong vòng một | Loop Exceptions In general a loop continues to perform iterations until its condition is no longer true. You use two actions to change this behavior continue and break. With the continue action you can stop the current iteration that is no further actions in that iteration will be executed and jump straight to the next iteration in a loop. For example var total Number 0 var i Number 0 while i 20 if i 10 continue total i The while statement in this script loops from 1 to 20 with each iteration adding the current value of i to a variable named total until i equals 10. At that point the continue action is invoked which means that no more actions are executed on that iteration and the loop skips to the eleventh iteration. This would create the following set of numbers 1 2 3 4 5 6 7 8 9 11 12 13 14 15 16 17 18 19 20 Notice that there is no number 10 indicating that no action occurred on the tenth loop. The break action is used to exit a loop even if the condition that keeps the loop working remains true. For example var total Number 0 var i Number 0 while i 20 total i if total 10 break This script increases the value of a variable named total by 1 with each iteration. When the value of total is 10 or greater as checked by an if statement a break action occurs and the while statement halts even though it s set to loop 20 times. In the following exercise you ll use continue and break in a simple search routine. 1. Open in the Lesson09 Assets folder. This file contains two layers Actions and Search Assets. The Actions layer will contain the search routine for this project. The Search Assets layer contains the text fields button and graphics for this exercise. In this exercise you ll produce a simple application that lets you enter a name in a search field to return the phone number for that individual. Two text fields are on the screen name_txt will be used to enter the name to search result_txt will display the search result. An invisible button .