AppleScript saving global variable I'd like to access the variables origTrack and origPlaylist from another AppleScript so that I can return to the track and playlist that were playing before the first script executed.

Here's what I have in the first script:

global origTrack
global origPlaylist

on run arguments
    if ((count of arguments) is 0) or (first item of arguments) is not "paused" then

        set origTrack to ""
        tell application "iTunes"
            if player state is playing then
                set origTrack to current track

            end if
        end tell

        set origPlaylist to ""
        tell application "iTunes"
            if player state is playing or player state is paused then
                set origPlaylist to current playlist
                set newPlaylist to playlist "Morning Mix"
                set view of front window to newPlaylist
            end if
        end tell
        tell application "iTunes" to play newPlaylist

    end if
    return arguments
end run


Second script:

on run
    set isPlaying to false

    tell application "iTunes"
        set isPlaying to player state is equal to playing
        pause
        set current track to origTrack
    end tell

    if isPlaying then
        return "playing"
    else
        return "paused"
    end if
end run
I usually save text files as the variable they are named after, and recall them in other scripts. I use a folder in /var, i created my own hidden folder so it wouldn't clutter it too much. You can make hidden folders with mkdir in terminal. Example: mkdir /var/.scriptvariables