Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Applescript > Re: exit repeat...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 5 Topic 1608 of 1612
Post > Topic >>

Re: exit repeat not exiting repeat. I repeat: exit repeat not exiting repeat. I repeat....

by Jerry Kindall <jerrykindall@[EMAIL PROTECTED] > May 1, 2008 at 08:27 PM

In article <joshuafwhalen-C515A8.19283301052008@[EMAIL PROTECTED]
>,
Joshua Whalen <joshuafwhalen@[EMAIL PROTECTED]
> wrote:

>                   get the sound volume
>                   if result > 1 then
>                      set MyVol to the result
>                   else
>                      if result < 5 then
>                         exit repeat
>                      end if
>                   end if

There's no reason to get the volume to a variable, subtract 1 from to
the variable, and set the volume to the variable.  Really, the whole
fadeout bit would be lot simpler as:

tell application "iTunes"
   repeat with v from its sound volume to 0 by -1
      set its sound volume to v
   end repeat
   set its sound volume to 0
end tell

Much simpler.

Similarly, the fadeup could be:

tell application "iTunes"
   repeat with v from its sound volume to 100 by 10
      set its sound volume to v
   end repeat
   set its sound volume to 100
end tell

Note that if you don't say "its sound volume" but rather "sound
volume," you will be affecting the system volume, not iTunes' ("sound
volume" is in a scripting addition and takes precedence over iTunes'
built-in terminology).

Also note that I explicitly set the sound volume to the minimum or
maximum after the loop, in case the loop doesn't take it all the way to
the top or the bottom of the scale as appropriate, as can happen when
you are stepping by 3 or whatever.

You can change the "by" to make it go faster.  If you need it to go
slower than 1 in either direction, you will need to insert a delay in
the repeat loop, like the "delay 0.1" you had in your example.

It might also be easier to just tell iTunes to "play playlist item 1 of
argv" rather than having a bunch of if clauses that do basically the
same thing.

-- 
Jerry Kindall, Seattle, WA                <http://www.jerrykindall.com/>

        Send only plain text messages under 32K to the Reply-To address.
        This mailbox is filtered aggressively to thwart spam and viruses.




 5 Posts in Topic:
exit repeat not exiting repeat. I repeat: exit repeat not exitin
Joshua Whalen <joshuaf  2008-05-01 19:28:48 
Re: exit repeat not exiting repeat. I repeat: exit repeat not ex
Jerry Kindall <jerryki  2008-05-01 20:27:31 
Re: exit repeat not exiting repeat. I repeat: exit repeat not ex
Joshua Whalen <joshuaf  2008-05-01 23:43:44 
Re: exit repeat not exiting repeat. I repeat: exit repeat not ex
Jolly Roger <jollyroge  2008-05-02 00:44:25 
Re: exit repeat not exiting repeat. I repeat: exit repeat not ex
Joshua Whalen <joshuaf  2008-05-04 03:43:22 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat May 17 5:54:33 CDT 2008.