Problem with scripting dictionary search

Hi Mark & Shane,

I’ve noticed this issue a long time ago (in some latest version of SD7 if I remember well) but always forgot to report.

tell application id "asDB"
	activate
	set theWin to open (path to application "Finder") showing script dictionary
	tell theWin to set search string to "open"
end tell

This snippet works well when compiled for the first time and always triggers an error in subsequent runs.
The only way to make it run is to replace search string with «property pSCH».
But, as you know, the raw syntax will be replaced at every compile time.


MacOS 12.6.3 (21G419)
Script Debugger 8.0.5 (8A61)

1 Like

Similar result here, plus the snippet below, copied from the SD dictionary also fails.

tell application "Script Debugger"
   tell dictionary window "Finder Dictionary"
      set search options to {search names, search descriptions, search classes}
      set search string to "folder" -- performs the search
   end tell
end tell

For me, the OP script compiles but never works.

I tried this:

tell application "Script Debugger"
   tell dictionary window "Finder Dictionary"
      set search options to {search names, search descriptions, search classes}
      set  |«property pSCH»| to "folder" -- performs the search
   end tell
end tell

And this does not error out, but does not work work. It silently fails.

→ Mac OS: 11.6.8 (20G730)
→ Script Debugger 8.0.5 (8A61)

@estockly, I have 3 comments on your post:

  • When using «property pSCH» you need to run the script before you compile it: copy the following snippet, paste it in a new window and run it without compiling.
  • If the dictionary window is already open, it will not come to front and will not update. That’s the goal of the first line of the snippet.
  • When you wrap the constant with pipes (i.e. |«property pSCH»|) you make it a variable. You code become similar to set myVariable to "folder'.
tell application id "asDB"
	activate
	set theWin to open (path to application "Finder") showing script dictionary
	tell theWin to set search string to "folder"
end tell

This is odd, because Script Debugger compiles scripts before running. Running an uncompiled script should be no different from running a compiled script.

Right (@alldritt and @ShaneStanley)?

I tried it in Script Editor and got different results.

First, it behaved the same way with «property pSCH». It worked if your run it and doesn’t work if you compile first.

but, with script editor, if you run the compiled script, and the search string does not change, it does not error out. But if you run the compiled script and it’s changing the search string it does error out. With Script Debugger it errors out either way, every time.

In the meantime, here is a workaround for the bug:

tell application id "asDB"
	activate
	set theWin to open (path to application "Finder") showing script dictionary
	set searchstring to "folder"
end tell
run script "tell application id \"asDB\" to tell dictionary window 1  to set «property pSCH» to \"" & searchstring & "\""

I think what @ionah means is running it so that it compiles only once – it’s any subsequent attempt to compile that will cause problems.

So it’s really not able to compile “search string” correctly. Sounds like a terminology conflict?

This is indeed a dictionary terminology conflict. Script Debugger’s application class’ search string property uses the code seSt while the dictionary window class’ search string property uses the code pSCH. Unfortunately, fixing this (making both properties use wither the seStor pSCH codes) is a breaking change.

My gut is to use the application class’ seSt code on the theory that dictionary window searches are less common that application searches.

Sorry Mark, I’m not sure to understand what you mean: english is not my mother tongue.
Are you saying that you will keep the terminology search string for the app class and change it for the dictionary class?
If it’s the case, that sounds perfect to me.