Referring to Finder from Loaded Script

Should I be able to refer to an app, say “Finder”, from a loaded script? For example, if I load this script “sub.scpt”:

on run (args)
	set p to item 1 of args
	display dialog p
	tell application "Finder"
		set a to "123"
	end tell
	display dialog a
end run

from here:

set s to load script alias "mainDrive:TEST:sub.scpt"
run script s with parameters {"abc"}

I get the “abc” but not the “123”.

Thanks very much for any input.

  • Dan

Hi Dan,

I’m afraid your example works as expected for me.

Best wishes

John M

Thanks for testing John - I take it you mean that you did get the “123”? That’s good news actually because I’ve got quite a bit invested in this and if the problem’s only mine then it’s fixable (somehow).

Thanks!

  • Dan

Hi Dan,

Yes, I got both dialogs.

Good luck

John M

Hi.

The only thing I can think of that would stop the second dialog appearing is clicking the “Cancel” button on the first.

I certainly wouldn’t put that past me so I tried it again but that wasn’t it. Interestingly, though, I found if I put a third display dialog back in the launching script after the run statement then all three appear, but if I take out that third one then only the first appears, not the second.

This of course is a pared-down script to represent a much larger one so I think I’ll concentrate on the live one I’m supposed to have working by now :(.