• 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: [ANN] Table dialogs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ANN] Table dialogs


  • Subject: Re: [ANN] Table dialogs
  • From: "Stockly, Ed" <email@hidden>
  • Date: Tue, 16 Feb 2016 17:11:57 +0000
  • Thread-topic: [ANN] Table dialogs

>
> To check whether my handler was working or not I ran a repeat loop making a 100
> versions of the original date and the text from that date, and displayed
> them side by side. Made it easy to spot the mistakes I¹d made in the
> handlers.  When others offered their versions of the same script I ran those
> through too and was instantly able to verify that they worked. (I¹ll post
> that script later, it¹s very short).



Just paste this into a script window and run. Myriad Tables Lib needs to be installed in the Script Libraries folder.


—————

use AppleScript version "2.4"
use scripting additions
use script "Myriad Tables Lib"

on DisplayDatesTable(tableData, tableTitle)
	set myTable to make new table with data tableData ¬
		with title tableTitle ¬
		with empty selection allowed
	modify columns in table myTable ¬
		date format "H:mm"
	set resultValue to display table myTable
end DisplayDatesTable

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

repeat 100 times
	-- set newTime to myTime # original instruction
	copy myTime to newTime # new one
	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
DisplayDatesTable(timeList, "Yvan1")
set timeList to {}

repeat 100 times
	set newTime to myTime # original instruction
	set time of newTime to random number from 1 to secsInADay
	newTime
	set TimeAsText to my DateToTimeText(newTime)
	copy {newTime, TimeAsText} to timePair
	--log timePair

	set the end of timeList to timePair
end repeat
DisplayDatesTable(timeList, "Yvan2")
set timeList to {}

repeat 100 times
	set newTime to myTime # original instruction
	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

	copy timePair to end of timeList
end repeat
DisplayDatesTable(timeList, "Yvan3")


on DateToTimeText(anyTime)
	set {theHour, theMinute} to {hours of anyTime, minutes of anyTime}
	if theHour is 0 then
		set theHour to 12
		set amOrPm to " a.m."
	else 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


References: 
 >RE: [ANN] Table dialogs (From: "Stockly, Ed" <email@hidden>)

  • Prev by Date: Re: [ANN] Table dialogs
  • Next by Date: Re: InDesign dialog box
  • Previous by thread: Re: [ANN] Table dialogs
  • Next by thread: Could AppleScript help here?
  • Index(es):
    • Date
    • Thread