text stringlengths 0 15.7k | source stringlengths 6 112 |
|---|---|
set the the chosen_parameters to (choose from list comparison_parameters with prompt "Pick the parameter(s) to use: (Command-key for multiple)" with multiple selections allowed) | lns3.scpt |
set the script_text to the script_text & "considering" & space & the parameter_string & CR | lns3.scpt |
set the script_text to the script_text & "end considering" | lns3.scpt |
set the script_text to the script_text & "end considering" & target_string & CR | lns3.scpt |
set the script_text to the script_text & "using terms from application \"" & target_string & "\"" & CR | lns3.scpt |
set the script_text to the script_text & tab & "-- insert actions here" & CR | lns3.scpt |
set the script_text to the script_text & "end using terms from" & CR | lns3.scpt |
set the replacement_string to "ApplicationName" | lns3.scpt |
set the script_text to the script_text & "tell application \"" & target_string & "\"" & CR | lns3.scpt |
set the script_text to the script_text & "end tell" & CR | lns3.scpt |
set the script_text to the script_text & "tell application \"System Events\"" & CR | lns3.scpt |
set the script_text to the script_text & "tell application \"Finder\"" & CR | lns3.scpt |
use framework "Carbon" | lns3.scpt |
on GetStringState(TheString) | lns3.scpt |
set TheString to TheString as text | lns3.scpt |
set LowercaseFound to false | lns3.scpt |
set UpperCaseFound to false | lns3.scpt |
set StringCharacter to characters of TheString | lns3.scpt |
repeat with TheCharacter in StringCharacter | lns3.scpt |
if (not LowercaseFound) then | lns3.scpt |
set LowercaseFound to ((id of "a") ≤ (id of TheCharacter)) and ((id of TheCharacter) ≤ (id of "z")) | lns3.scpt |
if (not UpperCaseFound) then | lns3.scpt |
set UpperCaseFound to ((id of "A") ≤ (id of TheCharacter)) and ((id of TheCharacter) ≤ (id of "Z")) | lns3.scpt |
if (UpperCaseFound and LowercaseFound) then set State to "MixedCase" | lns3.scpt |
if (not UpperCaseFound and not LowercaseFound) then set State to "NoLettersFound" | lns3.scpt |
if (UpperCaseFound and not LowercaseFound) then set State to "AllUpperCase" | lns3.scpt |
if (not UpperCaseFound and LowercaseFound) then set State to "AllLowerCase" | lns3.scpt |
return State | lns3.scpt |
end GetStringState | lns3.scpt |
on GetClassNameAsString(TheClass) | lns3.scpt |
return (current application's NSStringFromClass(TheClass's |class|())) as text | lns3.scpt |
end GetClassNameAsString | lns3.scpt |
on GetInheritancePath(CurrentClassName) | lns3.scpt |
script ReturnObj | lns3.scpt |
property Successful : false | lns3.scpt |
property ClassPath : "" | lns3.scpt |
local CurrentClass | lns3.scpt |
local ClassPath | lns3.scpt |
local NextClass | lns3.scpt |
local TheClass | lns3.scpt |
if (CurrentClassName = "NSObject") then return CurrentClassName | lns3.scpt |
set CurrentClass to current application's NSClassFromString(CurrentClassName) | lns3.scpt |
if (CurrentClass = missing value) then | lns3.scpt |
if (CurrentClassName = "") then | lns3.scpt |
display dialog "No characters were entered as input." buttons {"OK"} default button "OK" with title "Error" | lns3.scpt |
else if ((length of CurrentClassName) < 4) then | lns3.scpt |
display dialog "Invalid input. Only " & (length of CurrentClassName) & " character(s) was input" buttons {"OK"} default button "OK" with title "Error" | lns3.scpt |
set StringStatus to GetStringState(CurrentClassName) | lns3.scpt |
if (StringStatus = "AllUpperCase") then | lns3.scpt |
display dialog "Invalid input. All the text in the input, \"" & CurrentClassName & ",\" was all upper case." buttons {"OK"} default button "OK" with title "Error" | lns3.scpt |
else if (StringStatus = "AllLowerCase") then | lns3.scpt |
display dialog "Invalid input. All the text in the input, \"" & CurrentClassName & ",\" was all lower case." buttons {"OK"} default button "OK" with title "Error" | lns3.scpt |
else if (StringStatus = "NoLettersFound") then | lns3.scpt |
display dialog "Invalid input. There were no letters found in the input, \"" & CurrentClassName & "\"" buttons {"OK"} default button "OK" with title "Error" | lns3.scpt |
display dialog "Invalid input. The entered text \"" & CurrentClassName & ¬ | lns3.scpt |
"\" does not appear to represent a valid class name." buttons {"OK"} default button "OK" with title "Error" | lns3.scpt |
set (Successful of ReturnObj) to false | lns3.scpt |
return ReturnObj | lns3.scpt |
set ClassPath to CurrentClassName | lns3.scpt |
repeat until (GetClassNameAsString(CurrentClass) = "NSObject") | lns3.scpt |
set NextClass to CurrentClass's superclass() | lns3.scpt |
set ClassName to GetClassNameAsString(NextClass) | lns3.scpt |
set ClassPath to ClassName & "-->" & ClassPath | lns3.scpt |
set CurrentClass to NextClass | lns3.scpt |
set (ClassPath of ReturnObj) to ClassPath | lns3.scpt |
set (Successful of ReturnObj) to true | lns3.scpt |
display dialog "Error " & (errNum as string) ¬ | lns3.scpt |
& " occured getting the inheritance path." & return & return & errMsg with title "Error" buttons {"OK"} default button "OK" | lns3.scpt |
end GetInheritancePath | lns3.scpt |
"The class will be converted to an inheritance path" & return & ¬ | lns3.scpt |
"The input is case sensitive." with title "Enter a class" buttons {"OK", "Cancel"} default button "OK" default answer "" | lns3.scpt |
set StartingClass to text returned of result | lns3.scpt |
set TheResult to GetInheritancePath(StartingClass as text) | lns3.scpt |
if (Successful of TheResult) then | lns3.scpt |
"The arrow points to the class that is inheriting from its parent." with title ¬ | lns3.scpt |
"inheritance path" buttons {"OK"} default button "OK" cancel button "OK" default answer (ClassPath of TheResult) | lns3.scpt |
current application's NSPasteboard's generalPasteboard()'s pasteboardItems()'s firstObject()'s |types|() as list | lns3.scpt |
property NSRegularExpressionCaseInsensitive : a reference to 1 | lns3.scpt |
property NSNotFound : a reference to 9.22337203685477E+18 + 5807 -- see http://latenightsw.com/high-sierra-applescriptobjc-bugs/ | lns3.scpt |
set usPhoneNumberPattern to "\\(?(\\d{3})?\\)?\\s*-?\\s*(\\d{3})\\s*-?\\s*(\\d{4})" | lns3.scpt |
set theSample to "333-1234, 250-888-8888, (123) 350-1234, (456)-350-1234" | lns3.scpt |
set theRegEx to NSRegularExpression's regularExpressionWithPattern:usPhoneNumberPattern options:NSRegularExpressionCaseInsensitive |error|:(missing value) | lns3.scpt |
set theMatches to theRegEx's matchesInString:theSample options:0 range:[0, theSample's length] | lns3.scpt |
set thePhoneNumbers to {} | lns3.scpt |
set wholeRange to (aMatch's rangeAtIndex:0) as record | lns3.scpt |
set thePhoneNumber to text ((wholeRange's location) + 1) thru ((wholeRange's location) + (wholeRange's |length|)) of theSample | lns3.scpt |
set numRanges to aMatch's numberOfRanges as integer | lns3.scpt |
set parts to {"000", "000", "0000"} | lns3.scpt |
repeat with rangeIndex from 1 to numRanges - 1 | lns3.scpt |
set partRange to (aMatch's rangeAtIndex:rangeIndex) as record | lns3.scpt |
if partRange's location is not NSNotFound then ¬ | lns3.scpt |
set item rangeIndex of parts to text ((partRange's location) + 1) thru ((partRange's location) + (partRange's |length|)) of theSample | lns3.scpt |
set end of thePhoneNumbers to {|phoneNumber|:thePhoneNumber, parts:parts} | lns3.scpt |
thePhoneNumbers | lns3.scpt |
--> {
-- {phoneNumber:"333-1234", parts:{"000", "333", "1234"}}, | lns3.scpt |
set theNSStringSample to current application's NSString's stringWithString:theSample | lns3.scpt |
set theMatches to theRegEx's matchesInString:theNSStringSample options:0 range:{0, theNSStringSample's |length|()} | lns3.scpt |
set thePhoneNumber to (theNSStringSample's substringWithRange:wholeRange) as text | lns3.scpt |
if partRange's |length| > 0 then ¬ | lns3.scpt |
set item rangeIndex of parts to (theNSStringSample's substringWithRange:partRange) as text | lns3.scpt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.