• 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: what is the best way to 'unset' a variable
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: what is the best way to 'unset' a variable


  • Subject: Re: what is the best way to 'unset' a variable
  • From: Paul Berkowitz <email@hidden>
  • Date: Fri, 22 Mar 2002 19:16:33 -0800

On 3/22/02 7:02 PM, "Bill Hoffman" <email@hidden> wrote:

> I was just wondering if the net effect of each of these approaches to
> 'unsetting' a variable is the same, and if there is a 'preferred' choice
> for some reason?
>
> set x to ""
> set x to 0
> set x to null
> set x to missing value

If x is not a script property (properties persist over script runs), there's
no benefit to "unsetting" x at all, unlike for example setting variables to
Nothing in VBA. It doesn't inset them nor free up any memory: it's just
another operation Even with globals, which do still keep their value at the
end of a script, until it's run again. They will _have_ to be reset by your
script before they're used again. (Otherwise they would have errored
"variable is not defined": the first time).

In the case of properties, just reset them to whatever their initial value
is at the top of the script. Although if you don't want properties to
persist, why declare them as properties in the first place?

there is no advantage or disadvantage to initializing x to any one of your
options in preference to any other. And - as far as I know - no advantage to
"unsetting" hem at all. Just leave them be.
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: what is the best way to 'unset' a variable
      • From: Christopher Nebel <email@hidden>
    • Re: what is the best way to 'unset' a variable
      • From: John W Baxter <email@hidden>
    • Re: what is the best way to 'unset' a variable
      • From: Bill Hoffman <email@hidden>
References: 
 >what is the best way to 'unset' a variable (From: Bill Hoffman <email@hidden>)

  • Prev by Date: Re: Entourage "current identity" raw code not working
  • Next by Date: Re: what is the best way to 'unset' a variable
  • Previous by thread: what is the best way to 'unset' a variable
  • Next by thread: Re: what is the best way to 'unset' a variable
  • Index(es):
    • Date
    • Thread