Re: Match 'if' Condition and Do Nothing
Re: Match 'if' Condition and Do Nothing
- Subject: Re: Match 'if' Condition and Do Nothing
- From: Marconi <email@hidden>
- Date: Sun, 21 Dec 2003 09:30:25 -0700
At 8:20 PM -0600 12/20/03, Steve Mills wrote:
>
>
>
>You can do that. But it's it's simpler just to do this:
>
>
>
> if theCondition is LessLikely then
>
> Do some stuff
>
> else if theCondition is LeastLikely then
>
> do some different stuff
>
> end if
>
>
>
>
>
>as you can see, if the theCondition is MostLikely then nothing else happens,
>
>which is what you want.
>
>
But by including the most likely condition, you're making the loop faster (assuming it's in a loop) by only doing one test most of the time instead of doing 2 tests all the time. I assume this is why he put the first test in, because he said "to keep things efficient".
Exactly, Steve, this code is in a repeat loop and will be executed thousands of times in each run of the script.
I intentionally included the check for the most likely condition because that reduces the number of conditions checked for from two to one for the most likely condition.
Of course, it increases the number of checks for the less likely condition, but the probable ratio of Most Likely to Less Likely occurrences is such that (I think) I'm coming out ahead.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.