Setting times

set todayStart to (current date)

-- Try # 1
set {hours, minutes, seconds} of todayStart to {0, 0, 0}
-- Gets a forbidden message (Tiger)
-- Try #2
tell todayStart to set {hours, minutes, seconds} to {0, 0, 0}
-- Has no effect at all
-- Try #3
set hours of todayStart to 0
set minutes of todayStart to 0
set seconds of todayStart to 0
-- works as expected

todayStart

What’s the matter with the first two?

Hi,

This works:

set todayStart to (current date)
set {hours of todayStart, minutes of todayStart, seconds of todayStart} to {0, 0, 0}

I think you are trying to set hours to 0 when you want to set hours of todayStart to 0. If that makes any sense.

Best wishes

John M

I was shooting for lazy, John, hoping that {hours, minutes, seconds} of todayStart would compile into {hours of todayStart, minutes of todayStart, seconds of todayStart}

Yes. ‘Hours’ and ‘minutes’ are already defined as AppleScript constants and ‘seconds’ has a meaning in ‘with timeout’ blocks. You have to ensure that the compiler knows you mean the new properties of date objects. Another version of John’s suggestion would be:

tell todayStart to set {its hours, its minutes, its seconds} to {0, 0, 0}

Better still, in this case, use ‘time’, which is both faster and compatible with pre-Tiger systems:

set todayStart's time to 0

Thanks Nigel. Telling a variable is not something I’m familiar with.

set x to "One"
tell x to "Two"

confuses me.

Best wishes

John M

I think that one would confuse me too ” let alone x. :wink: