Lesson 5 - Repeat Loops - Applescript
Now, we will discuss "repeat loops".
Repeat loops are widely use to get an instance to recur under certain conditions or just forever.
Here's a basic example of how to use this:
Repeat loops are widely use to get an instance to recur under certain conditions or just forever.
Here's a basic example of how to use this:
set x to 0
repeat
set x to x + 1
end repeat
Simply, this just repeats forever.
We can use some other terminology to change how many times it repeats like in this example:
We can use some other terminology to change how many times it repeats like in this example:
set x to 0
repeat 1000 times
set x to x + 1
end repeat
This is a very basic example of what you can do with repeating a certain amount of times.
This next example will give you an example of repeat loops with variables.
This next example will give you an example of repeat loops with variables.
set x to 0
repeat while x is less than 5
set x to x + 1
end repeat
This example can be used with "greater than", "less than", "greater than or equal to", "less than or equal to", "equal to", and "is not".
In the next example, we will go over exceptions.
In the next example, we will go over exceptions.