Extra colon in path when Option key down in SD (FIXED ON RESTARTING)

EDIT: Ignore this report, unless it’s somehow useful. When I closed down SD and restarted it, the error described below did NOT occur. Stranger and stranger…

This is very, very strange, and it will take a moment to explain it. I have an ancient AppleScript app that uses code I wrote a dozen years, when I knew even less than I do now.

If the user holds down the Option key during startup, it displays a menu of options. This works perfectly when I run the app from the desktop. When I run the app from the Script Editor, with the Option key held down, an odd error occurs: the “(path to me)” text string seems to get an extra colon at the end, as shown in this screen shot:

This ONLY happens when I hold down the Option key when running the script from SD. If I do not hold down the Option key when running the script from SD, the script runs with no error (and this part of the script is run whether or not the Option key is held down, and runs BEFORE the script tests for the presence of the Option key.

Probably there is a feature in SD that I don’t know about that is causing this, and it’s another instance of user ignorance, but I’d be grateful to know if there’s a workaround.

FWIW, your code is potentially problematic. When you say:

((path to me) & "Some string") as text

what happens is that path to me returns an alias, the alias and “Some string” are concatenated into a list, and then that list is coerced into a string. As well as being inefficient, it also means the result depends on the state of text item delimiters. If your TIDS contain “:”, you would get the result you saw.

You should be using:

(path to me as text) & "Some string"

That means there is no coercion involved, no list is created, and no text item delimiters are involved.

A thousand thanks for this! My guess is that it explains some weirdness I’ve encountered in my scripts where a global variable that I set in that problematic way didn’t work inside a function, and I worked around the problem by setting the same variable again inside the function. Perhaps the coercion failed when the function read the variable? That’s just a guess, but I’ve gone through a dozen scripts and fixed this.

Thank you again. (That makes 1001.)