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 > exit repeat not...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 5 Topic 1608 of 1610
Post > Topic >>

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

by Joshua Whalen <joshuafwhalen@[EMAIL PROTECTED] > May 1, 2008 at 07:28 PM

Below is a script to run playlists in itunes, and then fade them to 
silence at a specified time. It is called by cron, with one of the 
following two lines:

52      2       26      4       *       osascript 
~/Library/Caches/RadioKnife/blade.scpt "4.26.082.52.44.AM" 52
50      2       26      4       *       osascript 
~/Library/Caches/RadioKnife/blade.scpt "1973 revisited"


the first line calls the fader, the second line calls the show. The 
second line, in this example, is actually called first. Sorry if that's 
confusing, both the crontab and the script are generated by an 
applescript studio application.

The problem I'm having is that the fader often fades past the beginning 
of the next playlist. Consequently, I've included a few conditionals:

If the sound volume is 0 or less, end repeat
and 
if NewShow is true, exit repeat

NewShow is sent when a new playlist is called. It's a global variable, 
although I have tried setting it up as property which defaults to false. 
Either way, it doesn't work. Neither does the While Sound volume  is 
greater than 0, repeat, end else approach.

I'm sure I've botched the syntax, once again. So, oh great masters of 
the applescript lexicon and grammer, help me? the entire script and 
crontab are below. Any clues will be appreciated. Those that work, 
especially so. If you want to test-run this, just change the playlist 
names to playlists you actually have.


TIA!

Joshua

======================================================================
======================================================================
TheScript:


global MyVol
global MyFadeRate
global MyEndTime
global MyDelay
global NewShow

on run argv
   with timeout of 99999 seconds
      
      if item 1 of argv = "4.26.082.52.44.AM" then
         set MyFadeRate to 0.068376068376
         set MyDelay to item 2 of argv
         set NewShow to false
         tell application "iTunes"
            get the sound volume
            set MyVol to the result
         end tell
         delay MyDelay
         repeat while NewShow is false
            delay MyFadeRate
            if NewShow is false then
               tell application "iTunes"
                  get the sound volume
                  if result > 1 then
                     set MyVol to the result
                  else
                     if result < 5 then
                        exit repeat
                     end if
                  end if
                  set MyVol to (MyVol - 1)
               end tell
            end if
            if NewShow is false then
               tell application "iTunes"
                  set the sound volume to MyVol
               end tell
            else
               if NewShow is true then
                  exit repeat
               end if
            end if
         end repeat
      end if
      
      if item 1 of argv = "1973 revisited" then
         set NewShow to true
         tell application "iTunes"
            set MyVol to 1
            repeat 10 times
               set the sound volume to (MyVol + 10)
               delay 0.1
            end repeat
            set the sound volume to 100
            play playlist "1973 revisited"
         end tell
      end if
      
      if item 1 of argv = "4.26.083.10.41.AM" then
         set MyFadeRate to 0.051282051282
         set MyDelay to item 2 of argv
         set NewShow to false
         tell application "iTunes"
            get the sound volume
            set MyVol to the result
         end tell
         delay MyDelay
         repeat while NewShow is false
            delay MyFadeRate
            if NewShow is false then
               tell application "iTunes"
                  get the sound volume
                  if result > 1 then
                     set MyVol to the result
                  else
                     if result < 5 then
                        exit repeat
                     end if
                  end if
                  set MyVol to (MyVol - 1)
               end tell
            end if
            if NewShow is false then
               tell application "iTunes"
                  set the sound volume to MyVol
               end tell
            else
               if NewShow is true then
                  exit repeat
               end if
            end if
         end repeat
      end if
      
      if item 1 of argv = "B5 Instrumental" then
         set NewShow to true
         tell application "iTunes"
            set MyVol to 1
            repeat 10 times
               set the sound volume to (MyVol + 10)
               delay 0.1
            end repeat
            set the sound volume to 100
            play playlist "B5 Instrumental"
         end tell
      end if
      
      if item 1 of argv = "4.30.085.07.42.AM" then
         set MyFadeRate to 0.076923076923
         set MyDelay to item 2 of argv
         set NewShow to false
         tell application "iTunes"
            get the sound volume
            set MyVol to the result
         end tell
         delay MyDelay
         repeat while NewShow is false
            delay MyFadeRate
            if NewShow is false then
               tell application "iTunes"
                  get the sound volume
                  if result > 1 then
                     set MyVol to the result
                  else
                     if result < 5 then
                        exit repeat
                     end if
                  end if
                  set MyVol to (MyVol - 1)
               end tell
            end if
            if NewShow is false then
               tell application "iTunes"
                  set the sound volume to MyVol
               end tell
            else
               if NewShow is true then
                  exit repeat
               end if
            end if
         end repeat
      end if
      
      if item 1 of argv = "music for evenings" then
         set NewShow to true
         tell application "iTunes"
            set MyVol to 1
            repeat 10 times
               set the sound volume to (MyVol + 10)
               delay 0.1
            end repeat
            set the sound volume to 100
            play playlist "music for evenings"
         end tell
      end if
      
      if item 1 of argv = "4.26.082.58.44.AM" then
         set MyFadeRate to 0.068376068376
         set MyDelay to item 2 of argv
         set NewShow to false
         tell application "iTunes"
            get the sound volume
            set MyVol to the result
         end tell
         delay MyDelay
         repeat while NewShow is false
            delay MyFadeRate
            if NewShow is false then
               tell application "iTunes"
                  get the sound volume
                  if result > 1 then
                     set MyVol to the result
                  else
                     if result < 5 then
                        exit repeat
                     end if
                  end if
                  set MyVol to (MyVol - 1)
               end tell
            end if
            if NewShow is false then
               tell application "iTunes"
                  set the sound volume to MyVol
               end tell
            else
               if NewShow is true then
                  exit repeat
               end if
            end if
         end repeat
      end if
      
      if item 1 of argv = "Frida Hyvonen" then
         set NewShow to true
         tell application "iTunes"
            set MyVol to 1
            repeat 10 times
               set the sound volume to (MyVol + 10)
               delay 0.1
            end repeat
            set the sound volume to 100
            play playlist "Frida Hyvonen"
         end tell
      end if
      
      if item 1 of argv = "5.1.082.04.45.PM" then
         set MyFadeRate to 0.0
         set MyDelay to item 2 of argv
         set NewShow to false
         tell application "iTunes"
            get the sound volume
            set MyVol to the result
         end tell
         delay MyDelay
         repeat while NewShow is false
            delay MyFadeRate
            if NewShow is false then
               tell application "iTunes"
                  get the sound volume
                  if result > 1 then
                     set MyVol to the result
                  else
                     if result < 5 then
                        exit repeat
                     end if
                  end if
                  set MyVol to (MyVol - 1)
               end tell
            end if
            if NewShow is false then
               tell application "iTunes"
                  set the sound volume to MyVol
               end tell
            else
               if NewShow is true then
                  exit repeat
               end if
            end if
         end repeat
      end if
      
      if item 1 of argv = "Fun" then
         set NewShow to true
         tell application "iTunes"
            set MyVol to 1
            repeat 10 times
               set the sound volume to (MyVol + 10)
               delay 0.1
            end repeat
            set the sound volume to 100
            play playlist "Fun"
         end tell
      end if
      
      if item 1 of argv = "4.27.089.09.31.PM" then
         set MyFadeRate to 0.0
         set MyDelay to item 2 of argv
         set NewShow to false
         tell application "iTunes"
            get the sound volume
            set MyVol to the result
         end tell
         delay MyDelay
         repeat while NewShow is false
            delay MyFadeRate
            if NewShow is false then
               tell application "iTunes"
                  get the sound volume
                  if result > 1 then
                     set MyVol to the result
                  else
                     if result < 5 then
                        exit repeat
                     end if
                  end if
                  set MyVol to (MyVol - 1)
               end tell
            end if
            if NewShow is false then
               tell application "iTunes"
                  set the sound volume to MyVol
               end tell
            else
               if NewShow is true then
                  exit repeat
               end if
            end if
         end repeat
      end if
      
      if item 1 of argv = "Be a HERO!" then
         set NewShow to true
         tell application "iTunes"
            set MyVol to 1
            repeat 10 times
               set the sound volume to (MyVol + 10)
               delay 0.1
            end repeat
            set the sound volume to 100
            play playlist "Be a HERO!"
         end tell
      end if
      
      if item 1 of argv = "5.1.083.08.31.PM" then
         set MyFadeRate to 0.076923076923
         set MyDelay to item 2 of argv
         set NewShow to false
         tell application "iTunes"
            get the sound volume
            set MyVol to the result
         end tell
         delay MyDelay
         repeat while NewShow is false
            delay MyFadeRate
            if NewShow is false then
               tell application "iTunes"
                  get the sound volume
                  if result > 1 then
                     set MyVol to the result
                  else
                     if result < 5 then
                        exit repeat
                     end if
                  end if
                  set MyVol to (MyVol - 1)
               end tell
            end if
            if NewShow is false then
               tell application "iTunes"
                  set the sound volume to MyVol
               end tell
            else
               if NewShow is true then
                  exit repeat
               end if
            end if
         end repeat
      end if
      
      if item 1 of argv = "Clash" then
         set NewShow to true
         tell application "iTunes"
            set MyVol to 1
            repeat 10 times
               set the sound volume to (MyVol + 10)
               delay 0.1
            end repeat
            set the sound volume to 100
            play playlist "Clash"
         end tell
      end if
      
   end timeout
end run

======================================================================
======================================================================

The Crontab:

52      2       26      4       *       osascript 
~/Library/Caches/RadioKnife/blade.scpt "4.26.082.52.44.AM" 52
50      2       26      4       *       osascript 
~/Library/Caches/RadioKnife/blade.scpt "1973 revisited"
10      3       26      4       *       osascript 
~/Library/Caches/RadioKnife/blade.scpt "4.26.083.10.41.AM" 47
59      2       26      4       *       osascript 
~/Library/Caches/RadioKnife/blade.scpt "B5 Instrumental"
07      5       30      4       *       osascript 
~/Library/Caches/RadioKnife/blade.scpt "4.30.085.07.42.AM" 51
05      5       30      4       *       osascript 
~/Library/Caches/RadioKnife/blade.scpt "music for evenings"
58      2       26      4       *       osascript 
~/Library/Caches/RadioKnife/blade.scpt "4.26.082.58.44.AM" 52
53      2       26      4       *       osascript 
~/Library/Caches/RadioKnife/blade.scpt "Frida Hyvonen"
04      14      1       5       *       osascript 
~/Library/Caches/RadioKnife/blade.scpt "5.1.082.04.45.PM" 45
45      12      1       5       *       osascript 
~/Library/Caches/RadioKnife/blade.scpt "Fun"
09      21      27      4       *       osascript 
~/Library/Caches/RadioKnife/blade.scpt "4.27.089.09.31.PM" 31
04      20      27      4       *       osascript 
~/Library/Caches/RadioKnife/blade.scpt "Be a HERO!"
08      15      1       5       *       osascript 
~/Library/Caches/RadioKnife/blade.scpt "5.1.083.08.31.PM" 40
30      12      1       5       *       osascript 
~/Library/Caches/RadioKnife/blade.scpt "Clash"




 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 Mon May 12 5:19:36 CDT 2008.