while

The AppleScript for loop (and while loop) examples

AppleScript for loop FAQ: How do I use an AppleScript for loop? (Also, how do you use an AppleScript while loop?)

This is actually a bit of a trick question, as there is no AppleScript for loop or while loop syntax. Instead you use the AppleScript repeat command, as shown in the following examples.

AppleScript for loop examples

Where you might expect an AppleScript for loop to iterate over a list, you use the AppleScript "repeat with" syntax:

An AppleScript list iterate/loop example

AppleScript list FAQ: How do I iterate/loop over an AppleScript list?

As I continue to work on my Mac speech recognition software projects, I've often found the need to loop over an AppleScript list. One way to loop over an AppleScript list is to use the AppleScript repeat with syntax:

The Perl until loop examples and syntax

Perl until loop FAQ: Can you share some examples of the Perl until loop syntax?

The Perl until loop is similar to the Perl while loop, but essentially does the opposite thing. Where the Perl while operator will run this loop forever:

while ('true')
{
  # do stuff here
}

the Perl until loop will never run this loop:

A Perl array and foreach example

Perl array foreach FAQ: How do I loop over every element in a Perl array with a for loop (or foreach loop)?

A friend recently asked how to create a simple array of numbers with Perl, and also how to iterate over that list of numbers in a Perl foreach loop. In this article I'll share with you the code I shared with him.

AppleScript repeat while examples

AppleScript while loop FAQ: Can you share some examples of the AppleScript while loop syntax (the AppleScript repeat while syntax)?

Instead of using a keyword like "while" to create loops, AppleScript uses the "repeat" keyword to create loops. There are several versions of this syntax, as follows.

AppleScript repeat syntax: Repeat X times

Here's how to repeat an AppleScript command X number of times:

AppleScript alarm clock - creating a time-based trigger

AppleScript alarm clock: Creating a time-based trigger.

I'm still working on my AppleScript iTunes alarm clock program, and looking for a way to set the alarm clock wake up time from the script itself. Earlier I was thinking about doing this using the Mac crontab facility, but somehow I don't think that's going to work for everyone. :)

Linux shell script - while loop and sleep example

Linux shell script FAQ: Can you share a Linux shell script while loop example? While you're at it, can you show how to use the sleep command in the shell script while loop?

Sure. As a little background, I've written a program I call an Email Agent that periodically scans my email inbox, and does a lot of things to the inbox, including deleting the over 6,000 spams that I receive in a typical day. A recent problem with the Agent is that it runs too fast, apparently overwhelming the sendmail process on the machine that it runs on.

Syndicate content