text
stringlengths
0
15.7k
source
stringlengths
6
112
end dispAlert:
lns1.scpt
on tableView:theTable heightOfRow:theRow
lns1.scpt
theTable's setIntercellSpacing:{0, 0}
lns1.scpt
return 19
lns1.scpt
end tableView:heightOfRow:
lns1.scpt
property _CR : return
lns1.scpt
property _TAB : tab
lns1.scpt
set numItems to nsItemURLList's |count|()
lns1.scpt
if (numItems > 1000) then
lns1.scpt
set msgStr to ¬
lns1.scpt
"You have a VERY LARGE number of items in your folder:" & _CR & folderToSearchPath ¬
lns1.scpt
& _CR & "Number of Items: " & numItems ¬
lns1.scpt
& _CR & _CR & ¬
lns1.scpt
"Are you SURE you want to proceed?" & _CR & _CR & "It could take many minutes to get the AppleScript List"
lns1.scpt
set oAns to (display dialog msgStr ¬
lns1.scpt
buttons {"No", "Yes"} ¬
lns1.scpt
"Yes" cancel button ¬
lns1.scpt
"No" with title ¬
lns1.scpt
"Get Entire Folder/Sub-Folder Contents" with icon stop)
lns1.scpt
if (button returned of oAns = "Yes") then
lns1.scpt
set folderItemList to (nsItemURLList's valueForKey:"path") as list
lns1.scpt
use framework "AppKit" -- needed for NSOpenPanel
lns1.scpt
use framework "Carbon" -- for user interaction
lns1.scpt
property openPanel : missing value
lns1.scpt
on chooseWithPrompt:thePrompt ofType:listOfExts defaultLocation:defLocAlias panelTitle:theTitle showInvisibles:invisFlag multiplesAllowed:multiFlag showPackageContents:packageFlag canChooseFiles:filesFlag canChooseFolders:foldersFlag resolveAliases:resolveFlag
lns1.scpt
if current application's AEInteractWithUser(-1, missing value, missing value) is not 0 then error number -1713 from current application
lns1.scpt
its performSelectorOnMainThread:"displayOpenPanelWithValues:" withObject:{prompt:thePrompt, ofType:listOfExts, defaultLocation:defLocAlias, showInvisibles:invisFlag, multiplesAllowed:multiFlag, showPackageContents:packageFlag, canChooseFiles:filesFlag, canChooseFolders:foldersFlag, resolveAliases:resolveFlag, panelTitle:theTitle} waitUntilDone:true
lns1.scpt
if returnCode is (current application's NSFileHandlingPanelCancelButton) then
lns1.scpt
set thePosixPaths to (openPanel's URLs()'s valueForKey:"path") as list
lns1.scpt
return thePosixPaths
lns1.scpt
end chooseWithPrompt:ofType:defaultLocation:panelTitle:showInvisibles:multiplesAllowed:showPackageContents:canChooseFiles:canChooseFolders:resolveAliases:
lns1.scpt
on displayOpenPanelWithValues:passedValues
lns1.scpt
if not (current application's NSThread's isMainThread()) as boolean then error "This handler must be called on the main thread." from current application
lns1.scpt
set {prompt:thePrompt, ofType:listOfExts, defaultLocation:defLocAlias, showInvisibles:invisFlag, multiplesAllowed:multiFlag, showPackageContents:packageFlag, canChooseFiles:filesFlag, canChooseFolders:foldersFlag, resolveAliases:resolveFlag, panelTitle:theTitle} to passedValues as record -- edited
lns1.scpt
set my openPanel to current application's NSOpenPanel's openPanel()
lns1.scpt
tell openPanel
lns1.scpt
its setMessage:thePrompt
lns1.scpt
its setAllowedFileTypes:listOfExts -- extensions or UTIs; missing value if it doesn't matter
lns1.scpt
its setDirectoryURL:(current application's class "NSURL"'s fileURLWithPath:(POSIX path of defLocAlias)) -- AS's default directory
lns1.scpt
its setShowsHiddenFiles:invisFlag
lns1.scpt
its setAllowsMultipleSelection:multiFlag
lns1.scpt
its setTreatsFilePackagesAsDirectories:packageFlag
lns1.scpt
its setCanChooseFiles:filesFlag
lns1.scpt
its setCanChooseDirectories:foldersFlag
lns1.scpt
its setResolvesAliases:resolveFlag
lns1.scpt
set my returnCode to openPanel's runModal()
lns1.scpt
end displayOpenPanelWithValues:
lns1.scpt
set thePosixPaths to its chooseWithPrompt:"Open file" ofType:{"txt", "pdf"} defaultLocation:(path to desktop) panelTitle:"Open" showInvisibles:false multiplesAllowed:true showPackageContents:false canChooseFiles:true canChooseFolders:true resolveAliases:true
lns1.scpt
set stringToSearch to "one
lns1.scpt
blah
lns1.scpt
Blah
lns1.scpt
more blah here
lns1.scpt
blaah"
lns1.scpt
set findString to "blah"
lns1.scpt
my findParsContaining:findString inString:stringToSearch matchCase:false
lns1.scpt
on findParsContaining:findString inString:stringToSearch matchCase:caseFlag
lns1.scpt
set stringToSearch to current application's NSString's stringWithString:stringToSearch
lns1.scpt
set escString to current application's NSRegularExpression's escapedPatternForString:findString
lns1.scpt
if caseFlag then
lns1.scpt
set theOptions to current application's NSRegularExpressionAnchorsMatchLines
lns1.scpt
set theOptions to (current application's NSRegularExpressionAnchorsMatchLines) + (get current application's NSRegularExpressionCaseInsensitive)
lns1.scpt
set theRegex to current application's NSRegularExpression's regularExpressionWithPattern:("^.*" & escString & ".*$") options:theOptions |error|:(missing value)
lns1.scpt
set theMatches to theRegex's matchesInString:stringToSearch options:0 range:{0, stringToSearch's |length|()}
lns1.scpt
set end of theResults to (stringToSearch's substringWithRange:(aMatch's range())) as text
lns1.scpt
return theResults
lns1.scpt
end findParsContaining:inString:matchCase:
lns1.scpt
set theClipboard to current application's NSPasteboard's generalPasteboard()
lns1.scpt
set theURLs to theClipboard's readObjectsForClasses:{current application's class "NSURL"} options:(missing value)
lns1.scpt
set theCount to theURLs's |count|()
lns1.scpt
property dictStack : missing value -- stack to hold array of dictionaries
lns1.scpt
property textInProgress : "" -- string to collect text as it is found
lns1.scpt
property anError : missing value -- if we get an error, store it here
lns1.scpt
on makeRecordWithXML:xmlString
lns1.scpt
set my dictStack to current application's NSMutableArray's array() -- empty mutable array
lns1.scpt
dictStack's addObject:(current application's NSMutableDictionary's |dictionary|()) -- add empty mutable dictionary
lns1.scpt
set my textInProgress to current application's NSMutableString's |string|() -- empty mutable string
lns1.scpt
set anNSString to current application's NSString's stringWithString:xmlString
lns1.scpt
set theData to anNSString's dataUsingEncoding:(current application's NSUTF8StringEncoding)
lns1.scpt
set theNSXMLParser to current application's NSXMLParser's alloc()'s initWithData:theData
lns1.scpt
theNSXMLParser's setDelegate:me
lns1.scpt
set theResult to theNSXMLParser's parse()
lns1.scpt
if theResult then -- went OK, get first item on stack
lns1.scpt
return ((my dictStack)'s firstObject()) as record
lns1.scpt
else -- error, so return error
lns1.scpt
error (my anError's localizedDescription() as text)
lns1.scpt
end makeRecordWithXML:
lns1.scpt
on parser:anNSXMLParser didStartElement:elementName namespaceURI:aString qualifiedName:qName attributes:aRecord
lns1.scpt
set parentDict to my dictStack's lastObject()
lns1.scpt
set childDict to current application's NSMutableDictionary's |dictionary|()
lns1.scpt
if aRecord's |count|() > 0 then
lns1.scpt
childDict's setValue:aRecord forKey:"attributes"
lns1.scpt
set existingValue to parentDict's objectForKey:elementName
lns1.scpt
if existingValue is not missing value then
lns1.scpt
if (existingValue's isKindOfClass:(current application's NSMutableArray)) as boolean then
lns1.scpt
set theArray to existingValue
lns1.scpt
set theArray to current application's NSMutableArray's arrayWithObject:existingValue
lns1.scpt
parentDict's setObject:theArray forKey:elementName
lns1.scpt
theArray's addObject:childDict
lns1.scpt
parentDict's setObject:childDict forKey:elementName
lns1.scpt
(my dictStack)'s addObject:childDict
lns1.scpt