• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
path to me (again)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

path to me (again)


  • Subject: path to me (again)
  • From: Mitchell L Model <email@hidden>
  • Date: Tue, 28 Jun 2016 12:16:16 -0400



[I am reposting because all my indentation disappeared in the last post, and it will be almost impossible to follow this without the indentation. My apologies.]

In the last installment of this puzzle, I asked naively why with this code:

        property pathToMe1 : (POSIX path of (path to me as text))
        property pathToMe2 : missing value
        set pathToMe2 to (POSIX path of (path to me as text))
        {pathToMe1, pathToMe2}

pathToMe1 is the path to Script Editor or Script Debugger
pathToMe2 i the path to the script, which is what I want

[Here is another in my series of explorations into the semantics and mechanisms of AppleScript. I apologize if the length of this one is not worth the mystery it presents, or if the mystery has an obvious explanation I should have seen. The mysteries are presented on lines beginning ***.]

pathToMe1 was the path to SD (or SE or whatever) but pathToMe1 was the path to the script. Shane Stanley explained that property values are compiled before the script exists. But now let’s take this a little further:

        property pathToMe1 : path to me                                -- (a)
        property pathToMe2 : missing value                                -- (b)
        property theScript : me                                                        -- (c)
        property theValue : 1                                                        -- (d)
        set pathToMe2 to path to me                                                -- (e)                
        set pathToMe3 to path to theScript                                -- (f)
        on setTheValue()
                set theScript's theValue to 2                                        -- (g)
                log theValue                                                                -- (h) = 1
                log theScript's theValue                                                -- (i) = 2
        end setTheValue
        setTheValue()

theScript contains itself, recursively.
Almost all of this makes sense, after taking into account Shane’s comment about what "me" means at compile time.

        when the script is compiled
                (a)        pathToMe1 is the path to the compiler
                (b)        pathToMe2 is initialized to missing value
                (c)        theScript is initialized as itself
                (d)        property theValue initialized to 1

        when the script is executed:
                (e)        pathToMe2 is set to the path to the script
                (f)        pathToMe3 is set to the path to theScript, whose value is the script
                (g)        theScript’s value is set to 2
        ***  (h)        theValue is 1
                (i)        theScript’s theValue is 2
        after the script is executed, just as during execution:
        ***   “theValue" is 1
                "theScript’s value" is 2
                "theScript is me" is true

*** What I can’t explain is how “theValue” is 1 but “theScript’s theValue” is 2, even though “theScript" equals “me”, and the script’s properties should be able to be modified inside the handler.

                

*** A further mystery: running this script with osascript, pathToMe1 is the path to osascript, BUT, “theValue” is 2 not 1.
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Re: path to script file in script's folder
  • Next by Date: Re: AppleScript "standard libraries" project - need to hand, off now
  • Previous by thread: Re: type string vs. text
  • Next by thread: Re: AppleScript "standard libraries" project - need to hand, off now
  • Index(es):
    • Date
    • Thread