• 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
Variables and command-line args
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Variables and command-line args


  • Subject: Variables and command-line args
  • From: Kevin Walzer <email@hidden>
  • Date: Mon, 02 Jun 2008 14:09:36 -0400
  • Organization: WordTech Communications LLC

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?

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
_______________________________________________
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: Variables and command-line args
      • From: Philip Aker <email@hidden>
    • Re: Variables and command-line args
      • From: "Mark J. Reed" <email@hidden>
  • Prev by Date: Re: SQLite install
  • Next by Date: Re: SQLite install
  • Previous by thread: Re: background color
  • Next by thread: Re: Variables and command-line args
  • Index(es):
    • Date
    • Thread