Processes - 'has scripting terminology'

I’ve been trying to convert my Mac OS 8/9 dictionary opening script to run in Mac OS X. It asks the user to choose from a list of the processes that have scripting terminology and opens the files of the selected ones in Script Editor. But the ‘has scripting terminology’ property of all processes (including scriptable ones) is set to ‘false’ in 10.2.4, which is clearly no help at all.

Is this another example of X lacking an ability of its predecessors, or is there some other logic at work here? How do I test for scriptable processes?

Based on the lengthy lists in the dialogs presented in script editors when listing applications to open, I have to assume that this isn’t possible yet.

A workaround, perhaps not very fast, is ask the process about its aete resource:

tell application "Whatever" to «event ascrgdte»

Thanks for the replies, guys. I didn’t have any luck with «event ascrgdte». All that came back was a very long and unintelligible data object.

A bit more poking around has shown what I should have guessed - that ‘has scripting terminology’ is correctly set in the processes’ application files, so I’ve thrown together this version of my old OS 8/9 script:

tell application "Finder"
  set {theFiles, theNames} to {application file, name} of application processes
  set eligibleNames to {}
  repeat with i from 1 to (count theFiles)
    if has scripting terminology of item i of theFiles then
      set the end of eligibleNames to item i of theNames
    end if
  end repeat
  set chosenNames to (choose from list eligibleNames with prompt ¬
    "Select the currently running application(s) whose " & ¬
    "dictionaries you wish to open:" default items {"Finder"} with multiple selections allowed)
  if the result is false then return
  repeat with i from 1 to (count chosenNames)
    open (get application file of process (item i of chosenNames)) using application file id "ToyS"
  end repeat
end tell

It can probably be improved, but it works very well - except that for some reason, I have to resize the opened dictionary windows before the text in them becomes visible. I think it’s something to do with the default size I’ve set for them in Script Editor. A snappier result would be possible if Finder scripting were as good in X as it is in 8.6 and 9.2.2, but the action here is very acceptable on a fast machine.

Thanks, Greg. :slight_smile: The OS 8/9 version’s in ScriptBuilders somewhere. When I’m a bit more aware of the “gotchas” in X, I’ll submit a finished X version there.

Nigel,
Nice to see this option you wrote come back so great. Nice code… Always will be in my scripts library. Do you have any more tricks up your sleeve. :slight_smile:

Nigel, I’ve found that I get errors on the ‘has scripting terminology’ command for some processes, so I added a TRY block trap, and ignore those that error. I also added an activate:


-- Nigel Garvey on macsripter.net BBS
tell application "Finder"
	set {theFiles, theNames} to {file, name} of application processes
	set eligibleNames to {}
	repeat with i from 1 to (count theFiles)
		try
			if has scripting terminology of item i of theFiles then
				set the end of eligibleNames to item i of theNames
			end if
		on error -- just skip anything that errors
		end try
	end repeat
	activate
	set chosenNames to (choose from list eligibleNames with prompt ¬
		"Select the currently running application(s) whose " & ¬
		"dictionaries you wish to open:" default items {"Finder"} with multiple selections allowed)
	if the result is false then return
	repeat with i from 1 to (count chosenNames)
		open (get application file of process (item i of chosenNames)) using application file id "ToyS"
	end repeat
end tell

Thanks, Krazay and Krioni, for the feedback! :slight_smile:

Krioni. Do the errors you found disappear if you reinstate ‘application file’ (instead of just ‘file’) in the first ‘set’ line? According to the Finder dictionary, application files should have - and are the only ones with - a ‘has scripting terminology’ property. On the other hand, you’d expect the file of an application process to be an application file anyway. If ‘theFiles’ are application files, you shouldn’t get errors when testing their ‘has scripting terminology’ properties. If they’re not application files, they shouldn’t be returned as the files of application processes. Strange… Have you identified the files concerned?

They still appear. Strangely enough, there are two problems:

  1. Some items have missing value for the ‘has scripting terminology’ property, even though they are listed in application processes, and have application files. Specifically on my TiBook:
    EPSON Launcher
    N065U Button Manager (scanner software)
    Classic Support

  2. Even more annoyingly/strangely, one application process has missing value for the name and application file properties. It DOES have a creator type, which is “bbox”. Anyone else want to take my bet that this is short for BlueBox, in other words, part of the Classic emulation environment?

I really wish Apple would do this correctly. If an application process is supposed to have certain properties, PUT THEM THERE! Anyway, my try block catches all this mess, and lets me go on with life. :slight_smile:

Ah, right. I see what’s happening now. It’s stuff that gets picked up when Classic’s running. Your fix seems to be the best way of dealing with this. Thanks. :slight_smile:

Verrrry handy!