Re: Run script with arguments
Re: Run script with arguments
- Subject: Re: Run script with arguments
- From: Nicola Vitacolonna <email@hidden>
- Date: Tue, 30 Dec 2014 08:52:49 +0100
> AppleScript's log command does nothing of itself other than provide the logged information to the host running the script; it's up to the host what it does with it. If you add other commands to the run handler, they don't appear in Script Editor's event log either, so it's not surprising that log commands don’t.
I don’t agree. The purpose of the log command is, well, to log information, and Script Editor windows have a Messages area to display such information. It looks at least counterintuitive that log commands do not have any visible effect, especially because that happens only when scripts are run via `run script` (and only starting with Yosemite, as far as I can tell). Ditto for osascript. Compare with:
script Foo
on run
set argv to {"a", 1}
repeat with i from 1 to (count argv)
log item i of argv
end repeat
return 42
end run
end script
run Foo
which is just fine. One thing I may agree with, however, is that the fact that `run script` accepts script objects is an undocumented feature (please correct me if I am wrong), so `run script Foo…` actually calls for undefined behavior.
> There's no problem with stdOut and no forked process, as this script shows:
> [snip]
Ok, good example. In fact, I haven’t thought about using Cocoa for the purpose of logging.
> OTOH, if you add a "use framework" statement to the top level of the above script, the "run script" call fails -- that looks to be a serious bug.
I have noticed that as well recently, but I thought that some (again, not documented) scoping rule is in effect.
> Is there some reason you need to call run?
Well, my use case is a bunch of “task” scripts that may call each other. Think of “build” and “install”:
script build
on run argv
-- Process build options and build
end
end
script install
run script build with parameters {"--fast", "--small", "--correct"}
-- install
end
You may argue that handlers would do the job as well here, but I have simplified the context somewhat.
Generally speaking, I think that the inability to call `run Foo` with parameters is a design flaw.
Nicola
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden