• 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
Duration of local variables
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Duration of local variables


  • Subject: Duration of local variables
  • From: "Marc K. Myers" <email@hidden>
  • Date: Sat, 19 May 2001 04:08:26 -0400
  • Organization: [very little]

If I run the following script repeatedly in Script Editor or as an
applet, the variable xPrime in the run handler increments. The variable
xPrime in the reset() handler does not. Can anyone tell me why? I
didn't expect the value of a local variable to be retained from
execution to execution. I'm using AS 1.6 under OS 9.1.

on run
try
set xPrime to xPrime + 1
on error
set xPrime to 1
end try
reset()
display dialog "[run] " & (xPrime as text)
end run

on reset()
try
set xPrime to xPrime + 1
on error
set xPrime to 1
end try
display dialog "[reset] " & (xPrime as text)
end reset

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

[5/19/01 4:02:17 AM]


  • Follow-Ups:
    • Re: Duration of local variables
      • From: Emmanuel <email@hidden>
  • Prev by Date: Re: Impossible "If"?
  • Next by Date: Re: directory listing
  • Previous by thread: Re: help needed-- probably a scoping problem
  • Next by thread: Re: Duration of local variables
  • Index(es):
    • Date
    • Thread