• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Run script with arguments
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Run script with arguments
      • From: Shane Stanley <email@hidden>
References: 
 >Run script with arguments (From: Nicola Vitacolonna <email@hidden>)
 >Re: Run script with arguments (From: Deivy Petrescu <email@hidden>)
 >Re: Run script with arguments (From: Nicola Vitacolonna <email@hidden>)

  • Prev by Date: Re: Run script with arguments
  • Next by Date: Re: Run script with arguments
  • Previous by thread: Re: Run script with arguments
  • Next by thread: Re: Run script with arguments
  • Index(es):
    • Date
    • Thread