Le 2016/02/03 à 16:09, S. J. Cunningham <
email@hidden> a écrit :
On Feb 2, 2016, at 9:09 PM, Stockly, Ed wrote:
I'm working on a script that will be used to manage event show times and
dates.
The idea is that the user will enter the dates times each show (stage,
concert, screening) is on, and then later all the shows airing within a
date range will be exported for print and/or web.
If, for example, the show plays every week with this schedule:
Tue-Thu at 7 pm; Fri-Sat 8 pm; Sat. and Sun. at 2 pm; Sun. at 6:30 pm
(This is fairly typical schedule).
What I want is a simple way to enter this data. (It would be stored in
some database) and a simple way to extract the dates and times that fall
within a range, and form a clear and precise text string, like the one
above.
Before I go about reinventing this wheel, has anyone done this kind of
thing in AppleScript before?
How about using an Excel spreadsheet for the UI? It has pretty good Applescript support. Or, if you are facile with it, Filemaker would be even better. You can make a nice input layout and output format and use Applescript or Filemaker scripting to handle the processing. Either of these would probably be better than tying to reinvent the wheel with AS, even using ASOC.
Steve
On 2015/08/20 I found this script :
-- Created 2015-08-20 by Shane Stanley
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
use script "BridgePlus" -- for pre-10.11 compatibility
if not (current application's NSThread's isMainThread()) as boolean then
display alert "This script must be run from the main thread." buttons {"Cancel"} as critical
error number -128
end if
-- create a view
set theView to current application's NSView's alloc()'s initWithFrame:(current application's NSMakeRect(0, 0, 100, 200))
-- create date picker
set datePicker to current application's NSDatePicker's alloc()'s initWithFrame:(current application's NSMakeRect(0, 0, 100, 100))
-- set style: choices are NSTextFieldAndStepperDatePickerStyle, NSClockAndCalendarDatePickerStyle, or NSTextFieldDatePickerStyle
datePicker's setDatePickerStyle:(current application's NSClockAndCalendarDatePickerStyle)
-- set elements: choices include NSHourMinuteDatePickerElementFlag, NSHourMinuteSecondDatePickerElementFlag, NSTimeZoneDatePickerElementFlag, NSYearMonthDatePickerElementFlag, and NSEraDatePickerElementFlag
datePicker's setDatePickerElements:((current application's NSYearMonthDayDatePickerElementFlag) + (current application's NSHourMinuteSecondDatePickerElementFlag as integer))
-- set initial date
datePicker's setDateValue:(current application's NSDate's |date|())
-- get the size it needs
set theSize to datePicker's fittingSize()
--resize the picker and view accordingly
theView's setFrameSize:theSize
datePicker's setFrameSize:theSize
-- add the picker to the view
theView's setSubviews:{datePicker}
-- create an alert
set theAlert to current application's NSAlert's alloc()'s init()
-- set up alert
tell theAlert
its setMessageText:"Pick a date"
its setInformativeText:"Any date"
its addButtonWithTitle:"OK"
its addButtonWithTitle:"Cancel"
its setAccessoryView:theView
end tell
-- show alert in modal loop
set returnCode to theAlert's runModal()
if returnCode = (current application's NSAlertSecondButtonReturn) then error number -128
-- retrieve date
set theDate to ASify from (datePicker's dateValue()) -- or simply coerce to date in 10.11
--> date "2015年8月20日木曜日 19:43:58"
Yvan KOENIG running El Capitan 10.11.3 in French (VALLAURIS, France) mercredi 3 février 2016 16:34:06