• 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: Bill Hoffman <email@hidden>
  • Date: Sat, 23 Mar 2002 00:07:22 -0800

On Friday, March 22, 2002, at 10:07 PM, John W Baxter wrote:

If a global is large (a long string, etc), then there is an advantage to
clearing it before reaching the end of the script: the script file on disk
will be smaller if the large string is "cleared" than if it isn't. I
think: experiment.

my question stems actually from the 'open file' thread.

say I'm rewriting a large-ish file or files, and inserting new content at the beginning of the file. I'm first reading the entire file into a temp variable with 'read file'. I then write my new content at the beginning of an empty file, write the whole file chunk from the file read temp variable into the file after that, close up and my new file is written. I'm talking about large files in the MB size range.

now I've got a temp variable (or I could have several of them) with the contents of an entire file in it hanging around that I no longer need or want. I was of the impression (apparently a wrong one) that 'unsetting' this temp variable once its useful life is over during the run time of the script would free up memory or otherwise contribute to efficiency in some way other than just anal tidiness, particularly if the variable(s) in question are huge.

I was also thinking along the lines of something like a script object 'destructor' function (just clearing a script object variable outright) for the same reasons. (I can just see the "why would you want to do that?" replies coming on that).

I guess the question I should have asked is: does it provide a useful benefit to 'unset' or clear a variable's data during runtime in AppleScript, not what's the cleverest way to do it.

Paul B. and others say no benefit is gained during runtime by setting a variable's data to "" or 0 or null so just let it be. Fine with me, I'm not inclined to be anally tidy if I don't need to be.

Thanks.
_______________________________________________
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: John W Baxter <email@hidden>
References: 
 >Re: what is the best way to 'unset' a variable (From: John W Baxter <email@hidden>)

  • Prev by Date: [OS X]getting email addresses with AppleScript
  • Next by Date: Need help, please: duplicate file name
  • Previous by thread: Re: 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