toggle playPause for iPhoto, script problem, probably global variable I need toggle playPause for iPhoto, so I wrote this script

global isPaused
try
    get isPaused
on error
    set isPaused to false
end try
tell application "iPhoto"
    if slideshow running then
        if isPaused then
            resume slideshow
        else
            pause slideshow
            set isPaused to true
        end if
    else
        start slideshow
    end if
end tell


I sent this command via ssh (with osascript -e '%s') and resume feature doesn't work (start and pause work correctly).

so I wrote helper script

try
    get toggle
on error
    set toggle to false
end try
tell application "iPhoto"
    if toggle then
        start slideshow
    else
        set toggle to true
    end if
end tell


it works correctly when I run it via AppleScript editor, but not if I run this code via ssh.

[edited]
I run scripts exactly this way:

osascript -e 'try
get toggle
on error
set toggle to false
end try
tell application "iPhoto"
if toggle then
start slideshow
else
set toggle to true
end if
end tell'
I solved my problem, global variable was reset, now I store variable in file, here is the code:

set thePath to (get path to scripts folder from user domain as text) &amp; “myTempFile.scpt"

script theData
    property IsPaused : missing value
end script

try
    set theData to load script file thePath
on error
    set IsPaused of theData to false
end try

tell application "iPhoto"
    if slideshow running then
        if isPaused of theData then
            resume slideshow
        set isPaused of theData to false
        else
            pause slideshow
            set isPaused of theData to true
        end if
    else
        start slideshow
    set isPaused of theData to false
    end if
end tell

store script theData in file thePath replacing yes
return IsPaused of theData