Script variable names are forced to lowercase

If I write something like

script TestScript
set testOfScript to ""
end script

it will SOMETIMES, not all the time, but usually when it starts doing it in a specific script it will keep on doing it, change the name as such

script testScript
set testofScript to ""
end script

Does anyone have any idea why? It’s driving me crazy that I can’t always keep the same naming conventions…

Model: iMac
Browser: Firefox 3.6.8
Operating System: Mac OS X (10.5)

Yes it does. AppleScript Editor seems to cache the variable names. The only way I found to clear that cache it to quit and relaunch the application.

For example, if in one script you call a variable as “testvariable” then in another script you can’t name a variable “testVariable”. It will rename it back to “testvariable”. However If you quit AppleScript Editor and then restart it, then you can use the second version. Quitting AppleScript Editor seems to clear the cache.

Hi, maeks84.

I see Hank’s already replied, but I think this may be a useful addition what he’s written.

Script Editor and AppleScript Editor standardise the cases of any particular label to what they were in the first instance of that label compiled in any particular session.

In other words, one of the following has happened:

  1. There’s a variable called testScript (with the lower-case first letter) earlier on in the script you’re compiling, or
  2. There’s a variable called testScript in another compiled script you have open in your editor, or
  3. One of the above has been true at some time since you launched the editor for this session.

A remedy which works with both Script Editor and AppleScript Editor, is to save your script, then quit the editor entirely and relaunch it. Compile the label you want to change, in the form you want, in an empty document (eg. TestScript). Then reopen the script you just saved. In Script Editor, the errant variable will now appear with the required cases. In AppleScript Editor, you’ll need to recompile the script.

There are variations on this method, and AppleScript Editor’s behaviour is slightly different from Script Editor’s, but the general idea, as Hank suggested, is to make sure the editor’s first sight of the compiled label is the form you want.

This method worked like a charm! Thanks guys, I’m so happy now! :smiley: