• 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
Crashing Script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Crashing Script


  • Subject: Crashing Script
  • From: "Stockly, Ed" <email@hidden>
  • Date: Fri, 12 Feb 2016 16:49:03 +0000
  • Thread-topic: Crashing Script

I have two problems with this script. The first is that if I uncomment the log command it crashes Script Editor (but not script debugger).

The second problem (which is why I’m using SE on it in the first place and why I’m logging commands) is that the results are whacked.

The main handler builds a list that contains an appleScript date with a random time; and a text representation of that time.

{date "Friday, February 12, 2016 at 3:40:16 am", "3:40 a.m.”} — for example.

Stepping through in SD, I can tell that the date and the text in the timePair variable match.

But when the timeList is returned at the end, none of the pairs match. When I comment out the log command in SE I get the same result.

So, does this script crash anyone else’s script editor?

Does anyone else get the same match, then mismatch I get?

And, why?

----------------------


set myTime to current date
set secsInADay to (24 * 60 * 60)
set timeList to {}
repeat 100 times
	set newTime to myTime
	set time of newTime to random number from 1 to secsInADay
	newTime
	set TimeAsText to my DateToTimeText(newTime)
	set timePair to {newTime, TimeAsText}
	--log timePair
	set the end of timeList to timePair
end repeat
return timeList

on DateToTimeText(anyTime)
	set {theHour, theMinute} to {hours of anyTime, minutes of anyTime}
	if theHour > 12 then
		set theHour to theHour - 12
		set amOrPm to " p.m."
	else
		set amOrPm to " a.m."
	end if
	if theMinute is 0 then
		set thisTime to (theHour as text) & amOrPm
	else
		if theMinute < 10 then
			set theMinute to "0" & (theMinute as text)
		else
			set theMinute to (theMinute as text)
		end if
		set thisTime to (theHour as text) & ":" & theMinute & amOrPm
	end if
	return thisTime
end DateToTimeText

 _______________________________________________
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: Crashing Script
      • From: Steve Mills <email@hidden>
    • Re: Crashing Script
      • From: Yvan KOENIG <email@hidden>
  • Prev by Date: Re: PSA: Does your app use Sparkle? Update it, or use an HTTPS server
  • Next by Date: Re: Crashing Script
  • Previous by thread: Re: PSA: Does your app use Sparkle? Update it, or use an HTTPS server
  • Next by thread: Re: Crashing Script
  • Index(es):
    • Date
    • Thread