Script does not utilize changes in library script

I edit the library script, save it, then recompile the main script. Unfortunately, the main script does not seem to be using the latest edit of the library script.

What else do I need to do to “refresh” the main script knowledge of the library changes?

It seems to have something to do with trying to recompile the main script with debugging turned on. If I have to turn debugging off and on after every change, it’s going to make for a long day.

Whenever you save changes to a library script you need to recompile any open scripts utilizing that library script. Turning debugging off and on causes a recompile which is what is actually fixing the problem.

You can use Option-Command-K to force a recompile or hold the Option key down when pressing the Compile button in the script window’s toolbar.

As mentioned, I did recompile the main script after every change to the library script.

It gets worse, when I turned off debugging and recompiled the script after making library script changes, everything worked fine - until I turned debugging back on in the main script. Then, it again acted as though it were using an older version of the script library file. That means I can’t use debugging, at all.

Something else, which may be related.
The original script had a property declaration:
property DirectJobsSearch:libFolderSearchlib’s DirectJobsSearch

As part of troubleshooting, I copied the handler inside the script library and renamed the copied portion as
DirectJobsSearchTwo

In the main script, I changed the property declaration to read:
property DirectJobsSearchTwo:libFolderSearchlib’s DirectJobsSearchTwo

It works find until I turn on debugging and try another recompile. The IDE immediately throws an error:
AppleScript Compile Error
Can’t make DirectJobsSearchTwo into type reference.

The only way to clear this error is to turn off debugging OR edit the property declaration back to its original form, using the original handler name DirectJobsSearch, recompile, then change again to the DirectJobsSearchTwo. At which point, it will recompile with script debugging on.

Note the above behavior continues even after I change the name of the original handler in the script library to
Used_to_be_DirectJobsSearch.

Note that I do make sure to save the script library file after each of these changes.

Which means, with script debugging on, the AppleScript compiler does not like an EXISTING handler name, but is perfectly happy with the old handler name, even though that name no longer exists in the script library.

Again, this seems like turning on script debugging is loading some previous version of the script library. It’s all very confusing.

Restarting seems to have cleared up the problem toggling between debugging on and off.

I now recall that two days ago, the power cord was accidentally disconnected from my Mac and I did not notice until the battery was discharged enough to force hibernation.

If the Mac did not recover “cleanly” from that state, it would explain the problem i was seeing.

I consider the problem solved. (You’d think after 20 years in IT that I would not have tried reboot earlier.)

1 Like