In earlier versions of SD, one could change the case of letters within a variable name (being sure to change all occurrences of the name) and get the changes to stick by just recompiling. Not sure when this stopped working, but it’s now failing for me.
I even tried changing all occurrences of a variable name to something completely different (xyzzy), recompiling, then changing the names back with the desired case changes. Upon recompiling again, the original variable name is restored with the original letter casing.
Is this happening to anyone else, or is it unique to my world?
You should be able to change the case in a variable’s name (assuming Script Debugger 6) – what matters is the case used for the first instance of the variable the compiler comes across.
There’s an expert preference that can turn this off. To turn it on, run this script:
use AppleScript version "2.4"
use framework "Foundation"
current application's NSUserDefaults's standardUserDefaults()'s setObject:true forKey:"PrefResetIdentifiersOnCompile"
I tried the expert script (with the boolean fix), but it didn’t help. I’m also seeing other bizarre behavior.
Here’s an example (this follows a fresh reboot while holding cmd-opt-P-R):
Open a new script window, delete my usual boilerplate text, and paste in a small script with a display dialog.
Save as a script applet to the Desktop, then close it.
Run the applet—no dialog appears.
Drag the applet icon onto SD icon to open—the pasted text is gone and the boilerplate is back.
When I look at the resources in the applet, I find:
a. /Contents/Resources/Scripts/main.scpt contains the boilerplate text.
b. /Contents/Resources/Scripts/main.recover.rtf contains the pasted script text.
It makes me wonder if my copy of SD or a prefs file is corrupt. Can I just drag the SD app to the trash and pull a new copy from the .dmg? Are there any preference or other files I should also drag to the trash? I don’t mind reentering registration info, resetting preferences, adding key shortcuts, etc.
Are there some variable that are “reserved” and case is fixed?
I can change SixDAysAgo to SixDaysAgo without any problem.
But FileName and fileName both change to filename (all lower case) in EVERY script I code them.
FileInfo changes to fileInfo (lower case f, upper case I). So it’s like certain variables can change but others cannot. Doesn’t matter if it’s the first variable in the script or not. I’ve made the entire script text, changed ALL occurrrences of the variable to the case I want, and re-compiled the script from the text version and the case still goes back to the unwanted form.
That’s right. That’s why use statements are important with libraries that use AppleScriptObjC: they tend to be case-sensitive, so their terminology should be loaded first.
One thing to keep in mind is that Cocoa has rules for what case the first character of a name is: for variables and methods it should be lowercase (except where the first word would normally be uppercase), and for class names, enums and constants it should be uppercase. The uppercase ones usually have a prefix, like NS.
This basically means you’re less likely to see changes happening if start variable names with lowercase letters.
And if you’re not happy with one, you can always use pipes to force things.