Re: Variable keeps changing with date manipulation in Snow Leopard
Re: Variable keeps changing with date manipulation in Snow Leopard
- Subject: Re: Variable keeps changing with date manipulation in Snow Leopard
- From: Max Bonilla <email@hidden>
- Date: Sun, 13 Sep 2009 17:15:29 -0400
- Thread-topic: Variable keeps changing with date manipulation in Snow Leopard
Hello,
Thanks to all who have responded. That was very helpful.
Yvan, my saying that the script worked well before Snow Leopard should have
been clarified, perhaps, because the handler MakeTimesRelativeToDate was not
used in SL; I added the handler, as I said in the original post, in order to
handle dates as now required under SL.
In the past, I used to manipulate dates in ways that I don't think were
"wrong" unless, for example, setting a time relative to a date can be
considered "wrong" under pre-SL. Obviously that is no longer possible.
Thanks for the help.
Max
> From: Yvan KOENIG <email@hidden>
> Date: Sun, 13 Sep 2009 10:49:15 +0200
> To: AppleScript <email@hidden>
> Subject: Re: Variable keeps changing with date manipulation in Snow Leopard
>
>
> Le Sep 12, 2009 à 9:59 PM, Max Bonilla a écrit :
>
> Of course, the RandomTime variable is not supposed to receive the
> LunchEndRelV value; I changed the handler to do so as an illustration
> of the problem.
>
> The script worked really well before,
>
>
> Really surprising statement.
>
> I ran your script under 10.4.11 with four log instructions:
>
> on createRandomTime(AvailableDates, NonAvailablestartTime,
> NonAvailableEndTime, DayBeginsV, DayEndsV, lunchbeginsv, LunchEndsV)
> set DayStart to 9
> set DayEndNUM to 16
> set xV to random number from 1 to (count of AvailableDates)
> set DateVar to item xV of AvailableDates
> set HourV to (random number from DayStart to (DayEndNUM))
> set HourV to HourV & ":00" as string
> set LunchStartRelV to my MakeTimesRelativeToDate(lunchbeginsv, DateVar)
> --Lunch ends at 1:30 PM on the next variable (LunchEndRelV) and it
> should stay that way for the duration of the script. Yet, see next
> note below.
> set LunchEndRelV to my MakeTimesRelativeToDate(LunchEndsV, DateVar)
> log LunchEndRelV
> set DayStartRelV to my MakeTimesRelativeToDate(DayBeginsV, DateVar)
> log LunchEndRelV
> set DayEndRelV to my MakeTimesRelativeToDate(DayEndsV, DateVar)
> log LunchEndRelV
> set startTime to my MakeTimesRelativeToDate(HourV, DateVar)
> log LunchEndRelV
>
> --LunchEndRelV changes to a different time every time the script is
> run (because HourV is a random number). But this is not what I want.
> return LunchEndRelV
> end createRandomTime
>
> The log report is:
>
> tell current application
> random number from 1 to 5
> 3
> random number from 9 to 16
> 14
> offset of ":" in "12:00"
> 3
> offset of ":" in "13:30"
> 3
> (*Wednesday, September 16, 2009 1:30:00 PM*)
> offset of ":" in "8:30"
> 2
> (*Wednesday, September 16, 2009 8:30:00 AM*)
> offset of ":" in "16:30"
> 3
> (*Wednesday, September 16, 2009 4:30:00 PM*)
> offset of ":" in "14:00"
> 3
> (*Wednesday, September 16, 2009 2:00:00 PM*)
> end tell
>
>
> Which shows that the time was already touched with old systems.
>
> Edit your handler like that:
>
> on createRandomTime(AvailableDates, NonAvailablestartTime,
> NonAvailableEndTime, DayBeginsV, DayEndsV, lunchbeginsv, LunchEndsV)
> set DayStart to 9
> set DayEndNUM to 16
> set xV to random number from 1 to (count of AvailableDates)
> set DateVar to item xV of AvailableDates
> set HourV to (random number from DayStart to (DayEndNUM))
> set HourV to HourV & ":00" as string
> copy my MakeTimesRelativeToDate(lunchbeginsv, DateVar) to
> LunchStartRelV
> --Lunch ends at 1:30 PM on the next variable (LunchEndRelV) and it
> should stay that way for the duration of the script. Yet, see next
> note below.
> copy my MakeTimesRelativeToDate(LunchEndsV, DateVar) to LunchEndRelV
> log LunchEndRelV
> copy my MakeTimesRelativeToDate(DayBeginsV, DateVar) to DayStartRelV
> log LunchEndRelV
> copy my MakeTimesRelativeToDate(DayEndsV, DateVar) to DayEndRelV
> log LunchEndRelV
> copy my MakeTimesRelativeToDate(HourV, DateVar) to startTime
> log LunchEndRelV
>
> --LunchEndRelV changes to a different time every time the script is
> run (because HourV is a random number). But this is not what I want.
> return LunchEndRelV
> end createRandomTime
>
> and it will behave as wanted.
>
> Yvan KOENIG (VALLAURIS, France) dimanche 13 septembre 2009 10:35:41
>
>
>
>
>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> AppleScript-Users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> net
> Archives: http://lists.apple.com/archives/applescript-users
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden