if then, else, end if

if then, else statements are a very important part of AppleScripting or any programming for that matter. The statement is relatively simple to construct and are about the only way to compare variables. Say you want to determine if you need a coat for today; depending on the temperature you could make the decision. If the temperature is lower than 50 degrees, you should probably take a coat. Let’s take a look at a simple pseudocode that describes this situation.

The temperature is 67.
if the temperature is lower than 50 degrees
    You should wear a coat
else
    You'll be fine without a coat.
end if

Here is how the statement would look with the variables declared.

Code for theTemperature

This simple applescript can be modified to use ranges rather than a set temperature. For instance, if the temperature is between -200 and 50 degrees and 51 and 200 degrees. The lower and upper range is set to an extreme [at least for IL] so that nothing could be left out.

0 Responses to “if then, else, end if”



  1. No Comments Yet

Leave a Reply




 

May 2008
S M T W T F S
     
 123
45678910
11121314151617
18192021222324
25262728293031

Top Posts

  • None

Top Clicks

  • None

Recent Comments

Archives