Re: Variables and command-line args
Re: Variables and command-line args
- Subject: Re: Variables and command-line args
- From: Philip Aker <email@hidden>
- Date: Mon, 02 Jun 2008 11:53:15 -0700
On 08-06-02, at 11:09, Kevin Walzer wrote: I'm trying to pass an argument to an AppleScript from the command line, but keep running into problems with scope. Here's a simple example:
property myName : [] --initialize the variable
on run args set item 1 of args to myName -- pass the value of arg 1 to myName return myName end run
I run this script in Terminal with this command:
osascript name.applescript Name
I expect to get the value "Name" as output. Instead, I get a blank line, apparently because I have set the value of myName to [] when defining it as a property.
I thought that setting myName as a property would make it global in scope, and that the value could be reset from within a handler. How can I pass the value of arg 1 to the myName variable?
property some_name : "bob"
on run theArgList set n to item 1 of theArgList return n & " and " & some_name end run
osascript args.applescript betty
--> betty and bob
Philip Aker
Democracy: Two wolves and a sheep voting on lunch.
|
_______________________________________________
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