• 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: Removable Disks (wrapping code)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Removable Disks (wrapping code)


  • Subject: Re: Removable Disks (wrapping code)
  • From: Nigel Garvey <email@hidden>
  • Date: Wed, 12 Nov 2003 02:07:29 +0000

"John W. Baxter" wrote on Tue, 11 Nov 2003 13:45:24 -0800:

>On 11/11/2003 6:21, "Arthur Knapp" <email@hidden> wrote:

>>> if month of (current date) is January then set newMonth to "01"
>>> if month of (current date) is February then set newMonth to "02"
>>
>> Hi. I'm sure this works fine, but I just wanted to point out that
>> repeatedly calling a scripting addition can be a bit slow. Why not save
>> it to a variable:
>>
>> set current_date to current date


>However, the reason you don't want multiple current date calls, but want to
>use a variable set once, is...
>
>Consider just this part:
>>> if month of (current date) is January then set newMonth to "01"
>>> if month of (current date) is February then set newMonth to "02"
>>> ...
>
>Now start the script such that the first call to current date happens at the
>very end of December, and the rest of the calls happen in January.

Well yes. That's one reason you don't want multiple current date calls.
There *is* a slight possibility that somebody who wasn't invited to a New
Year's Eve party and who didn't want to watch Jules Holland on the telly
might happen to run the script at 0.1 seconds to midnight. ;-)

> There
>will be no successful tests, and newMonth will be unset. (There are also
>opportunities to use the day and the month from different calls where the
>month changed between...if the day is obtained first, you could have
>February 31.)

And even with just one current date call, there are issues if a run of
Chris's script straddles midnight. It might get a perfectly valid date,
but apply it to a folder created the following day. More significantly,
starting a split second later, it might obtain the date just after
midnight and give the folder an inappropriate name for the previous day's
files.

>Correct results are always more important than speed, size of code, or
>anything else. For a suitable definition of "correct."

I'm sure that Arthur, like me, would agree that correct results are a
requirement of any script. :-) Given that, attention to speed, size of
code, and anything else are good attitudes of mind - part of the pursuit
of excellence that should characterise any human endeavour.

NG
_______________________________________________
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.

  • Prev by Date: Re: any chance of getting digests #2135 - 2148 from anyone?
  • Next by Date: Re: Removable Disks (wrapping code)
  • Previous by thread: Re: Removable Disks (wrapping code)
  • Next by thread: Re: Removable Disks (wrapping code)
  • Index(es):
    • Date
    • Thread