• 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: Date Variables that modify themselves! Huh?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Date Variables that modify themselves! Huh?


  • Subject: Re: Date Variables that modify themselves! Huh?
  • From: John W Baxter <email@hidden>
  • Date: Wed, 4 Jul 2001 07:59:05 -0700

The problem is that the set in the second line of
> set DateTimeNow to (current date)
> set DateTimeSend to DateTimeNow --this fails
> --set DateTimeSend to (current date) --this works

makes DateTimeSend be a variable which SHARES one date object with
DateTimeNow. Later, you use one of the names for that date object to
modify the object.

A better fix--because of the possible date change between the two current
date calls--would be

set DateTimeNow to (current date)
-- set DateTimeSend to DateTimeNow --this fails
copy DateTimeNow to DateTimeSend --this works

...

Now there are two variables each of which has its own date object (which
are equal at this moment).

I see no reason why the code as supplied should be wrapped in a tell
application "Finder" block. But perhaps the code is extracted from
something larger, some of which does use the Finder. I've tested the
revision, but not inside a tell application "Finder" block.

--John


At 14:17 +0100 7/4/2001, Guy Parker wrote:
>This seems like weird behaviour to me but maybe I'm being dumb! Any ideas?
>
>In the example as written below the action of modifying one variable
>(DateTimeSend) affects another variable (DateTimeNow) from which the first
>was derived. If the line containing "--this fails" is replaced by the one
>containing "--this works" then the action of modifying one variable does not
>affect the other.
>
>How is it that modifying one variable affects another from which it was
>originally derived? Maybe it is a date related issue but it seems strange to
>me!

>
>I would prefer to use just one instance of "current date" since there is a
>(small) risk that more than just the time could be different if it is used
>twice.
>
>Thanks,
>
>Guy
>
>tell application "Finder"
> set DateTimeNow to (current date)
> set DateTimeSend to DateTimeNow --this fails
> --set DateTimeSend to (current date) --this works
>
> set DelayTime to 10800 --set time to 3am
>
> display dialog "These should both be identical:
>" & (DateTimeNow as text) & "
>" & (DateTimeSend as text)
>
> set time of DateTimeSend to DelayTime
>
> display dialog "These should both be different:
>" & (DateTimeNow as text) & "
>" & (DateTimeSend as text)
>
>end tell
>_______________________________________________
>applescript-users mailing list
>email@hidden
>http://www.lists.apple.com/mailman/listinfo/applescript-users

--
John Baxter email@hidden Port Ludlow, WA, USA


References: 
 >Date Variables that modify themselves! Huh? (From: Guy Parker <email@hidden>)

  • Prev by Date: Re: Suggestions for improvements to scripting QuarkXPress ...
  • Next by Date: Re: Date Variables that modify themselves! Huh?
  • Previous by thread: Re: Date Variables that modify themselves! Huh?
  • Next by thread: Re: Date Variables that modify themselves! Huh?
  • Index(es):
    • Date
    • Thread