• 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: newbie question: define a variable?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: newbie question: define a variable?


  • Subject: Re: newbie question: define a variable?
  • From: "Marc K. Myers" <email@hidden>
  • Date: Sat, 29 Dec 2001 02:41:01 -0500
  • Organization: [very little]

> Date: Wed, 26 Dec 2001 12:25:59 -0800
> From: u7u <email@hidden>
> To: email@hidden
> Subject: newbie question: define a variable?
>
> Hello list:
> I am having trouble finding appleScript documentation on simple
> activities like defining a variable. Any pointers to such documentation
> would be appreciated.
>
> The following gives an error "variable w not defined." I have tried
> several different syntaxes, but I guess I'm not hitting the mark on
> simply defining a variable.
>
> any help greatly appreciated.

In AppleScript you define a variable by naming it and giving it a value.

set w to 0

copy 0 to w

Your script seems to assume that the variable "w" will be created with a
value of 0. AppleScript doesn't work that way. You can create a
property, a kind of persistent variable, with a property statement at
the top of the script, like this:

property w:0

Zero would be its initial value, but it will retain any value you might
give it later and retain it across executions of the script.

Marc K. Myers <email@hidden>
http://AppleScriptsToGo.com
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074

[12/29/01 2:39:55 AM]


  • Prev by Date: Re: why won't this compile?
  • Next by Date: Specifying OS X/9 versions of an app [LONG] [WAS: Re: why won't this compile?]
  • Previous by thread: newbie question: define a variable?
  • Next by thread: Re: newbie question: define a variable?
  • Index(es):
    • Date
    • Thread