• 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: Variable keeps changing with date manipulation in Snow Leopard
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Variable keeps changing with date manipulation in Snow Leopard


  • Subject: Re: Variable keeps changing with date manipulation in Snow Leopard
  • From: Yvan KOENIG <email@hidden>
  • Date: Sun, 13 Sep 2009 10:49:15 +0200


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:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
  • Follow-Ups:
    • Re: Variable keeps changing with date manipulation in Snow Leopard
      • From: Max Bonilla <email@hidden>
References: 
 >Variable keeps changing with date manipulation in Snow Leopard (From: Max Bonilla <email@hidden>)

  • Prev by Date: Re: date/Snow Leopard changed
  • Next by Date: Re: Variable keeps changing with date manipulation in Snow Leopard
  • Previous by thread: Re: Variable keeps changing with date manipulation in Snow Leopard
  • Next by thread: Re: Variable keeps changing with date manipulation in Snow Leopard
  • Index(es):
    • Date
    • Thread