text
stringlengths 0
15.7k
| source
stringlengths 6
112
|
---|---|
set errMsg to "ASObjC RegEx ERROR #" & errNum & LF & errMsg
|
lns1.scpt
|
display dialog errMsg & LF & ¬
|
lns1.scpt
|
"(error msg is on Clipboard)" with title (name of me) with icon stop
|
lns1.scpt
|
end regexFind:inString:findAll:
|
lns1.scpt
|
use script "CalendarLib EC" version "1.1.3"
|
lns1.scpt
|
property theCalendarName : "Privat" -- Set your calendar
|
lns1.scpt
|
set theQuery to "22:30 Fenster öffnen"
|
lns1.scpt
|
set theString to (current application's NSString's stringWithString:theQuery)
|
lns1.scpt
|
set theNSDataDetector to current application's NSDataDetector's dataDetectorWithTypes:(current application's NSTextCheckingTypeDate) |error|:(missing value)
|
lns1.scpt
|
set theMatch to (theNSDataDetector's firstMatchInString:theString options:0 range:{location:0, |length|:theString's |length|()})
|
lns1.scpt
|
if theMatch ≠ missing value then
|
lns1.scpt
|
set theStartDate to theMatch's |date|() as date
|
lns1.scpt
|
if theStartDate < (current date) then set theStartDate to theStartDate + 1 * days
|
lns1.scpt
|
set theMatch_Range to theMatch's range()
|
lns1.scpt
|
set theMatch_Range_Location to theMatch_Range's location
|
lns1.scpt
|
set theMatch_String to theString's substringWithRange:theMatch_Range
|
lns1.scpt
|
if (theMatch_Range_Location > 0) and (theMatch_Range_Location + (theMatch_Range's |length|()) ≠ theString's |length|()) then
|
lns1.scpt
|
set theString_withoutFoundDate to my regexReplace(theString as string, " *" & theMatch_String & " *", space)
|
lns1.scpt
|
set theString_withoutFoundDate to my regexReplace(theString as string, " *" & theMatch_String & " *", "")
|
lns1.scpt
|
set theString_withoutFoundDate to theString as string
|
lns1.scpt
|
set theCalendar to fetch calendar theCalendarName cal type cal cloud event store theStore
|
lns1.scpt
|
set theEvent to create event event store theStore destination calendar theCalendar event summary theString_withoutFoundDate starting date theStartDate ending date theEndDate
|
lns1.scpt
|
store event event theEvent event store theStore
|
lns1.scpt
|
set theIcon to POSIX file "/System/Library/PrivateFrameworks/CalendarUIKit.framework/Versions/A/Resources/App-empty.icns" as alias -- MS (12.5.1)
|
lns1.scpt
|
set theIcon to POSIX file "/System/Applications/Calendar.app/Contents/Resources/App-empty.icns" as alias -- MBP (10.15.7)
|
lns1.scpt
|
set theDate_FormattatedText to my formatDateString(theStartDate)
|
lns1.scpt
|
display dialog theString_withoutFoundDate & linefeed & theDate_FormattatedText with title "Created event" with icon theIcon
|
lns1.scpt
|
display dialog theString_withoutFoundDate & linefeed & "" with title "Created event" with icon theIcon
|
lns1.scpt
|
if the error_number is not -128 then display alert "Error: \"Create event\"" message error_message as warning
|
lns1.scpt
|
on regexReplace(theText, thePattern, theRepacement)
|
lns1.scpt
|
set theString to current application's NSString's stringWithString:theText
|
lns1.scpt
|
set newString to theString's stringByReplacingOccurrencesOfString:(thePattern) withString:(theRepacement) options:(current application's NSRegularExpressionSearch) range:{location:0, |length|:length of theText}
|
lns1.scpt
|
set newText to newString as string
|
lns1.scpt
|
if the error_number is not -128 then display alert "Error: Handler \"regexReplace\"" message error_message as warning
|
lns1.scpt
|
on formatDateString(theDate)
|
lns1.scpt
|
set theDateFormatter to current application's NSDateFormatter's alloc()'s init()
|
lns1.scpt
|
set theDateFormatter's timeZone to current application's NSTimeZone's localTimeZone()
|
lns1.scpt
|
set theDateFormatter's locale to current application's NSLocale's currentLocale()
|
lns1.scpt
|
set theDateFormatter's dateFormat to "yyyy-MM-dd 'um' HH:mm"
|
lns1.scpt
|
set theDate_FormattatedText to (theDateFormatter's stringFromDate:theDate) as string
|
lns1.scpt
|
if the error_number is not -128 then display alert "Error: Handler \"formatDateString\"" message error_message as warning
|
lns1.scpt
|
end formatDateString
|
lns1.scpt
|
set tabStatus to folders open in new tabs of Finder preferences
|
lns1.scpt
|
set folders open in new tabs of Finder preferences to false
|
lns1.scpt
|
open (path to documents folder)
|
lns1.scpt
|
set folders open in new tabs of Finder preferences to tabStatus
|
lns1.scpt
|
property dictCache : missing value -- we cache strings dictionaries here to speed multiple lok-ups a bit
|
lns1.scpt
|
on localizedStringFor:baseString inBundle:fileOrNSURL destLang:destLangCode sourceLang:sourceLangCode
|
lns1.scpt
|
set theBundle to current application's NSBundle's bundleWithURL:fileOrNSURL
|
lns1.scpt
|
set sourceLangString to current application's NSString's stringWithString:sourceLangCode
|
lns1.scpt
|
set destLangString to current application's NSString's stringWithString:destLangCode
|
lns1.scpt
|
set theURLs to theBundle's URLsForResourcesWithExtension:"strings" subdirectory:"" localization:sourceLangString
|
lns1.scpt
|
if theURLs's |count|() < 2 and (sourceLangString's containsString:"_") as boolean then
|
lns1.scpt
|
set sourceLangString to sourceLangString's substringToIndex:2
|
lns1.scpt
|
if theURLs's |count|() < 2 then
|
lns1.scpt
|
set sourceLangString to (current application's NSLocale's localeWithLocaleIdentifier:"en")'s localizedStringForLocaleIdentifier:sourceLangString
|
lns1.scpt
|
if theURLs's |count|() < 2 then error "No " & sourceLangCode & " localization found"
|
lns1.scpt
|
repeat with sourceURL in theURLs
|
lns1.scpt
|
if not (sourceURL's URLByDeletingLastPathComponent()'s lastPathComponent()'s isEqualToString:"Resources") as boolean then
|
lns1.scpt
|
set theData to (current application's NSData's alloc()'s initWithContentsOfURL:sourceURL)
|
lns1.scpt
|
if theData is missing value then error "No " & sourceLangCode & " localization found"
|
lns1.scpt
|
set sourceDict to (current application's NSPropertyListSerialization's propertyListWithData:theData options:0 format:0 |error|:(missing value))
|
lns1.scpt
|
set theKey to (sourceDict's allKeysForObject:baseString)'s firstObject()
|
lns1.scpt
|
if theKey is not missing value then
|
lns1.scpt
|
set stringsFileName to sourceURL's lastPathComponent()'s stringByDeletingPathExtension()
|
lns1.scpt
|
set localURL to (theBundle's URLForResource:stringsFileName withExtension:"strings" subdirectory:"" localization:destLangString)
|
lns1.scpt
|
if localURL is missing value and (destLangString's containsString:"_") as boolean then
|
lns1.scpt
|
set destLangString to (destLangString's substringToIndex:2)
|
lns1.scpt
|
if localURL is missing value then
|
lns1.scpt
|
set destLangString to ((current application's NSLocale's localeWithLocaleIdentifier:"en")'s localizedStringForLocaleIdentifier:destLangString)
|
lns1.scpt
|
if localURL is missing value then error "No " & destLangCode & " localization found"
|
lns1.scpt
|
set theData to (current application's NSData's alloc()'s initWithContentsOfURL:localURL)
|
lns1.scpt
|
if theData is missing value then error "No " & destLangCode & " localization found"
|
lns1.scpt
|
set destDict to (current application's NSPropertyListSerialization's propertyListWithData:theData options:0 format:0 |error|:(missing value))
|
lns1.scpt
|
set destValue to (destDict's objectForKey:theKey)
|
lns1.scpt
|
if destValue is not missing value then return {destValue as text, stringsFileName as text}
|
lns1.scpt
|
end localizedStringFor:inBundle:destLang:sourceLang:
|
lns1.scpt
|
set theURL to path to application "Finder"
|
lns1.scpt
|
my localizedStringFor:"System Preferences" inBundle:theURL destLang:"fr" sourceLang:"en"
|
lns1.scpt
|
set theBundle to current application's NSBundle's bundleWithURL:theURL
|
lns1.scpt
|
set sourceURL to theBundle's URLForResource:"Localizable" withExtension:"strings" subdirectory:"" localization:"en"
|
lns1.scpt
|
tell application "Safari" to set theXML to source of front document
|
lns1.scpt
|
set theXML to current application's NSXMLDocument's alloc()'s initWithXMLString:theXML options:(current application's NSXMLDocumentTidyHTML) |error|:(missing value)
|
lns1.scpt
|
if theXML = missing value then my displayError:"Impossible de récupérer la page active au forlat XML."
|
lns1.scpt
|
set allTables to (theXML's nodesForXPath:"//table" |error|:(missing value))
|
lns1.scpt
|
if allTables = missing value then my displayError:"Safari n'a renvoyé aucun tableau."
|
lns1.scpt
|
set theTable to allTables's firstObject()
|
lns1.scpt
|
return ((theTable's nodesForXPath:"./tr/td[1]" |error|:(missing value))'s valueForKey:"stringValue")
|
lns1.scpt
|
on displayError:errMess
|
lns1.scpt
|
tell application "Safari" to display alert "La lecture des alias a échoué :" message errMess buttons {"Annuler"} cancel button 1
|
lns1.scpt
|
end displayError:
|
lns1.scpt
|
current application's NSDictionary's dictionaryWithContentsOfFile:"/System/Library/CoreServices/SystemVersion.plist"
|
lns1.scpt
|
property currApp : a reference to current application
|
lns1.scpt
|
set x to currApp's NSHomeDirectory()
|
lns1.scpt
|
set pathHome to POSIX path of (path to home folder)
|
lns1.scpt
|
currApp's NSString's stringWithString:"42"
|
lns1.scpt
|
set x to "hello world"
|
lns1.scpt
|
set the_file to ((path to desktop as text) & "hello_world.txt") as «class furl»
|
lns1.scpt
|
display dialog "Error: " & errMess & " (" & errNum & ")" -- or whatever
|
lns1.scpt
|
write x to dataStream as list
|
lns1.scpt
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.