text
stringlengths
0
15.7k
source
stringlengths
6
112
«event !©Mt!©dT» {"One", "Two", "Three", "Four", "Five"}
lns3.scpt
«event !©Mt!©dT» {"One", "Two", "Three", "Four", "Five"} with «class mlsl» and «class empL» given «class appr»:"Simple table", «class prmp»:"Pick several, or none at all"
lns3.scpt
«event !©Mt!©dT» {1, 2, 3, 4, 5} given «class prmp»:"Pick an integer"
lns3.scpt
«event !©Mt!©dT» {1.1, 2.2, 3.3, 4.4, 5.5} given «class prmp»:"Pick a real"
lns3.scpt
«event !©Mt!©dT» {1.0, 2, 3, 4, 5} given «class prmp»:"Pick a real"
lns3.scpt
set someDate to current date
lns3.scpt
«event !©Mt!©dT» {someDate, someDate + 1 * days, someDate + 2 * days, someDate + 3 * days, someDate + 4 * days} given «class prmp»:"Pick a date"
lns3.scpt
«event !©Mt!©dT» {{true, "One"}, {false, "Two"}, {true, "Three"}, {false, "Four"}, {true, "Five"}} given «class prmp»:"This shows checkboxes, but they can't be clicked"
lns3.scpt
«event !©Mt!©dT» {{true, "One"}, {false, "Two"}, {true, "Three"}, {false, "Four"}, {true, "Five"}} with «class empL» given «class !©Ec»:{1}, «class prmp»:"These checkboxes can be clicked"
lns3.scpt
«event !©Mt!©dT» {{true, "One"}, {false, "Two"}, {true, "Three"}, {false, "Four"}, {true, "Five"}} given «class !©Ec»:{1}, «class !©Ch»:{"", "Number"}, «class prmp»:"These columns have headings"
lns3.scpt
«event !©Mt!©dT» {{true, "One", 1}, {false, "Two", 2}, {true, "Three", 3}, {false, "Four", 4}, {true, "Five", 5}} with «class !©Ad» given «class !©Ec»:{}, «class prmp»:"You can insert/add/delete and edit every cell"
lns3.scpt
«event !©Mt!©dT» {{missing value, "One"}, {false, "Two"}, {missing value, "Three"}, {missing value, "Four"}, {true, "Five"}} given «class !©Ec»:{1}, «class !©Rt»:{true, ""}, «class prmp»:"You can edit the checkboxes — some are in mixed-state mode"
lns3.scpt
«event !©Mt!©dT» {{missing value, "One"}, {false, "Two"}, {missing value, "Three"}, {missing value, "Four"}, {true, "Five"}} given «class !©Ec»:{1}, «class !©Rt»:{boolean, text}, «class prmp»:"You can edit the checkboxes — some are in mixed-state mode"
lns3.scpt
«event !©Mt!©dT» {{"One", true, "One"}, {"Two", false, "Two"}, {"Three", true, "Three"}, {"Four", false, "Four"}, {"Five", true, "Five"}} given «class !©Ec»:{1, 2}, «class !©Ch»:{"Number", "", "Match"}, «class !©Rt»:{"", true, {1, {"One", "Two", "Three"}}}, «class prmp»:"Everything here is editable — popups are always editable"
lns3.scpt
«event !©Mt!©dT» {{"One", true, "One"}, {"Two", false, "Two"}, {"Three", true, "Three"}, {"Four", false, "Four"}, {"Five", true, "Five"}} given «class !©Ec»:{1, 2}, «class !©Ch»:{"Number", "", "Match"}, «class !©Rt»:{"", true, {2, {"One", "Two", "Three"}}}, «class prmp»:"Everything here is editable — combo boxes are always editable"
lns3.scpt
«event !©Mt!©dT» {{true, "One"}, {false, "Two"}, {true, "Three"}, {false, "Four"}, {true, "Five"}} with «class !©Rn» given «class prmp»:"This table has row numbers"
lns3.scpt
«event !©Mt!©dT» {{"One", "One", true}, {"Two", "One" & return & "two", true}, {"Three", "One" & return & "two" & return & "three", true}, {"Four", "One" & return & "two" & return & "three" & return & "four", true}, {"Five", "One" & linefeed & "two" & linefeed & "three" & linefeed & "four" & linefeed & "five", false}} with «class !©El» given «class prmp»:"This table allows multiple lines within cells"
lns3.scpt
set theTable to «event !©Mt!©Td» {{true, "One"}, {false, "Two"}, {true, "Three"}, {false, "Four"}, {true, "Five"}} with «class !©Rn» given «class prmp»:"Note the new button titles"
lns3.scpt
«event !©Mt!©Tm» theTable given «class okbt»:"Continue", «class cnbt»:"Stop"
lns3.scpt
set theTable to «event !©Mt!©Td» {{true, "One"}, {false, "Two"}, {true, "Three"}, {false, "Four"}, {true, "Five"}} with «class !©Rn» given «class prmp»:"Note the rules between columns, highlighted rows and alternate background shading"
lns3.scpt
«event !©Mt!©Tm» theTable with «class !©Ab» given «class !©Gs»:«constant !©GS!©gV», «class !©Hr»:{1, 2}
lns3.scpt
set theTable to «event !©Mt!©Td» {{true, "One"}, {false, "Two"}, {true, "Three"}, {false, "Four"}, {true, "Five"}} with «class !©Rn» given «class prmp»:"You can reorder rows by dragging them up or down"
lns3.scpt
«event !©Mt!©Tm» theTable with «class !©Rd»
lns3.scpt
set theTable to «event !©Mt!©Td» {{1, "One", 100, "One hundred"}, {2, "Two", 200, "Two hundred"}, {3, "Three", 300, "Three hundred"}, {4, "Four", 400, "Four hundred"}, {5, "Five", 400, "Five hundred"}} with «class !©Rn» given «class !©Ch»:{"No", "Text", "No", "Text"}, «class prmp»:"Note the matching column widths"
lns3.scpt
«event !©Mt!©Tm» theTable given «class !©Gs»:«constant !©GS!©gV», «class !©Cw»:{1, 2, 1, 2}
lns3.scpt
set theTable to «event !©Mt!©Td» {{true, "One", 1}, {false, "Two", 2}, {true, "Three", 3}, {false, "Four", 4}, {true, "Five", 5}} given «class !©Ch»:{"", "Number"}, «class !©Rt»:{true, "", missing value}, «class prmp»:"Note how clicking on the heading sorts using the hidden number column, not alphabetically"
lns3.scpt
«event !©Mt!©Mc» theTable given «class !©Cl»:{2}, «class !©Sc»:3
lns3.scpt
set theColors to {{"Red", 1}, {"Orange", 2}, {"Yellow", 3}, {"Green", 4}, {"Blue", 5}, {"Indigo", 6}, {"Violet", 7}}
lns3.scpt
set theTable to «event !©Mt!©Td» theColors with «class !©Rn» given «class prmp»:"You can reorder the colors by dragging them up or down, and sorting will return them to the correct order", «class !©Rt»:{"", missing value}, «class !©Ch»:{"Rainbow"}
lns3.scpt
«event !©Mt!©Mc» theTable given «class !©Cl»:{1}, «class !©Sc»:2
lns3.scpt
set theTable to «event !©Mt!©Td» theColors with «class !©Rn» given «class prmp»:"You can reorder the colors by dragging them up or down, and this time sorting is disabled", «class !©Rt»:{"", missing value}, «class !©Ch»:{"Rainbow"}
lns3.scpt
«event !©Mt!©Mc» theTable given «class !©Cl»:{1}, «class !©Ss»:«constant !©So!©No»
lns3.scpt
set theTable to «event !©Mt!©Td» {{1.0, "One", 1.1}, {2.0, "Two", 2.2}, {3.0, "Three", 3.3}, {4.0, "Four", 4.4}, {5.0, "Five", 5.5}} given «class !©Ch»:{"Reals", "Text", "Reals"}, «class prmp»:"Note the different column formatting here"
lns3.scpt
set theTable to «event !©Mt!©Td» {{1.0, "One" & return & "two", 1.1}, {2.0, "Two", 2.2}, {3.0, "Three" & linefeed & "four" & linefeed & "five", 3.3}, {4.0, "Four", 4.4}, {5.0, "Five", 5.5}} with «class !©El» given «class !©Ch»:{"Reals", "Text", "Reals"}, «class !©Ec»:{2}, «class prmp»:"Note the different column formatting here"
lns3.scpt
use AppleScript version "2.5" -- 10.11 or later
lns3.scpt
property NSUserDefaults : a reference to current application's NSUserDefaults
lns3.scpt
property theDefaults : missing value
lns3.scpt
on prepare storage for theFile : missing value for domain domainString : missing value default values defaultsRecord : missing value write lock lockFile : true
lns3.scpt
if defaultsRecord is not missing value and class of defaultsRecord is not record then error "The 'prepare storage' command requires a record for the 'default values' parameter" to record
lns3.scpt
if theFile is missing value then
lns3.scpt
if domainString is missing value then error "The 'prepare storage' command requires either a 'for' or 'for domain' parameter"
lns3.scpt
set theResult to NSUserDefaults's alloc()'s initWithSuiteName:domainString
lns3.scpt
if theResult = missing value then error "The 'prepare storage' command was unable to initialize user defaults. Unknown error"
lns3.scpt
set my theDefaults to theResult
lns3.scpt
set bundleURL to |NSURL|'s fileURLWithPath:(POSIX path of theFile)
lns3.scpt
if (current application's NSRunningApplication's currentApplication()'s bundleURL()'s isEqual:bundleURL) as boolean then -- must be running as applet
lns3.scpt
set my theDefaults to NSUserDefaults's standardUserDefaults()
lns3.scpt
else -- being run by editor
lns3.scpt
set theData to current application's NSData's dataWithContentsOfURL:(bundleURL's URLByAppendingPathComponent:"Contents/Info.plist")
lns3.scpt
if theData = missing value then error "The file passed to the 'prepare storage' command is not a valid applet or script bundle"
lns3.scpt
set infoDict to current application's NSPropertyListSerialization's propertyListWithData:theData options:0 format:(missing value) |error|:(missing value)
lns3.scpt
if infoDict = missing value then error "The file passed to the 'prepare storage' command is not a valid applet or script bundle"
lns3.scpt
set newID to infoDict's objectForKey:"CFBundleIdentifier"
lns3.scpt
if newID = missing value then error "The file passed to the 'prepare storage' command does not have a bundle ID"
lns3.scpt
set theResult to NSUserDefaults's alloc()'s initWithSuiteName:newID
lns3.scpt
if lockFile then (current application's NSFileManager's defaultManager()'s setAttributes:{NSFilePosixPermissions:292} ofItemAtPath:(POSIX path of theFile & "/Contents/Resources/Scripts/main.scpt") |error|:(missing value)) -- the equivalent of -r--r--r--
lns3.scpt
if defaultsRecord is not missing value then
lns3.scpt
theDefaults's registerDefaults:defaultsRecord
lns3.scpt
on error errMessage
lns3.scpt
error "The 'prepare storage' command failed to assign defaults, with the error: " & errMessage
lns3.scpt
end prepare storage
lns3.scpt
on assign value theValue to key theKey
lns3.scpt
if class of theKey is not text then error "The 'assign value' command requires a string for its 'key' parameter" to text
lns3.scpt
accessDefaults()'s setObject:theValue forKey:theKey
lns3.scpt
error "The 'assign value' command failed, with the error: " & errMessage
lns3.scpt
end assign value
lns3.scpt
on value for key theKey
lns3.scpt
if class of theKey is not text then error "The 'value for key' command requires a string for its direct parameter" to text
lns3.scpt
set theResult to accessDefaults()'s objectForKey:theKey
lns3.scpt
if theResult is missing value then return missing value
lns3.scpt
return item 1 of ((current application's NSArray's arrayWithObject:theResult) as list)
lns3.scpt
end value for key
lns3.scpt
on assign file theValue to key theKey
lns3.scpt
if class of theKey is not text then error "The 'assign file' command requires a string for its 'key' parameter" to text
lns3.scpt
set theURL to |NSURL|'s fileURLWithPath:(POSIX path of theValue)
lns3.scpt
if theURL = missing value then error "The 'assign file' command was passed an invalid file"
lns3.scpt
accessDefaults()'s setURL:theURL forKey:theKey
lns3.scpt
error "The 'assign file' command failed, with the error: " & errMessage
lns3.scpt
end assign file
lns3.scpt
on file for key theKey
lns3.scpt
if class of theKey is not text then error "The 'file for key' command requires a string for its direct parameter" to text
lns3.scpt
set theResult to accessDefaults()'s URLForKey:theKey
lns3.scpt
set theResult to theResult as «class furl»
lns3.scpt
end file for key
lns3.scpt
on assign alias theValue to key theKey
lns3.scpt
if class of theKey is not text then error "The 'assign alias' command requires a string for its 'key' parameter" to text
lns3.scpt
if theURL = missing value then error "The 'assign alias' command was passed an invalid alias"
lns3.scpt
set theBookmark to theURL's bookmarkDataWithOptions:0 includingResourceValuesForKeys:{} relativeToURL:(missing value) |error|:(missing value)
lns3.scpt
if theBookmark = missing value then error "The 'assign alias' command was unable to create a bookmark for the file"
lns3.scpt
accessDefaults()'s setObject:theBookmark forKey:theKey
lns3.scpt
error "The 'assign alias' command failed, with the error: " & errMessage
lns3.scpt
end assign alias
lns3.scpt
on alias for key theKey
lns3.scpt
if class of theKey is not text then error "The 'alias for key' command requires a string for its direct parameter" to text
lns3.scpt
set theData to accessDefaults()'s dataForKey:theKey
lns3.scpt
if theData is missing value then return missing value
lns3.scpt
set theURL to |NSURL|'s URLByResolvingBookmarkData:theData options:0 relativeToURL:(missing value) bookmarkDataIsStale:(missing value) |error|:(missing value)
lns3.scpt
if theURL is missing value then return missing value
lns3.scpt
set theAlias to theURL as alias
lns3.scpt
return theAlias
lns3.scpt