text
stringlengths
0
15.7k
source
stringlengths
6
112
my performSelectorOnMainThread:"runWorkflow:" withObject:{theURL, theInput} waitUntilDone:true
lns1.scpt
if theError is not missing value then error theError's localizedDescription() as text
lns1.scpt
set appName to nsAppName's stringByDeletingPathExtension() as text
lns1.scpt
set defaultApp to my getDefaultApp("scpt")
lns1.scpt
on getDefaultApp(pExtStr)
lns1.scpt
set thePath to (POSIX path of (path to temporary items)) & "temp." & pExtStr
lns1.scpt
set nsCurApp to current application
lns1.scpt
nsCurApp's NSFileManager's defaultManager()'s createFileAtPath:thePath |contents|:(missing value) attributes:(missing value)
lns1.scpt
set ws to nsCurApp's NSWorkspace's sharedWorkspace()
lns1.scpt
set nsAppURL to ws's URLForApplicationToOpenURL:(nsCurApp's |NSURL|'s fileURLWithPath:thePath)
lns1.scpt
set {nsResult, nsAppName, nsError} to nsAppURL's getResourceValue:(reference) forKey:(nsCurApp's NSURLLocalizedNameKey) |error|:(reference)
lns1.scpt
set appName to nsAppName as text
lns1.scpt
set appName to text 1 thru ((offset of "." in (appName as text)) - 1) of appName
lns1.scpt
return appName
lns1.scpt
end getDefaultApp
lns1.scpt
set {theResult, theName, theError} to theURL's getResourceValue:(reference) forKey:(current application's NSURLLocalizedNameKey) |error|:(reference)
lns1.scpt
theName as text
lns1.scpt
set menuItems to {}
lns1.scpt
repeat with i from 0 to 30000
lns1.scpt
set end of my menuItems to i -- 'my' is equivalent to using 'a reference to' menuItems.
lns1.scpt
set menuItems to NSMutableArray's arrayWithArray:menuItems
lns1.scpt
set newMenuItems to menuItems's mutableCopy()
lns1.scpt
use script "Dialog Toolkit Plus" version "1.0"
lns1.scpt
property colorPopup : 1
lns1.scpt
property colorPopupList : {"Red", "Green", "Blue"}
lns1.scpt
set {theButtons, minWidth} to create buttons {"Cancel", "This sample shows how to build a reasonably complex dialog", "OK"} default index 3 cancel index 1 -- with equal widths
lns1.scpt
set {colorPopup, popupLabel, theTop} to create labeled popup colorPopupList bottom 16 popup width 100 max width accViewWidth label text "Job is for:" popup left 70 popup default colorPopup
lns1.scpt
set allControls to {colorPopup, popupLabel}
lns1.scpt
set {buttonName, controlsResults} to display enhanced window "Complex sample" acc view width accViewWidth acc view height theTop acc view controls allControls button list theButtons with align cancel button
lns1.scpt
set colorPopup to (item 1 of controlsResults)
lns1.scpt
if colorPopup = "Red" then
lns1.scpt
set colorPopup to 1
lns1.scpt
else if colorPopup = "Green" then
lns1.scpt
set colorPopup to 2
lns1.scpt
set colorPopup to 3
lns1.scpt
property theDirectoryPath_Default : POSIX path of (path to desktop)
lns1.scpt
property theAllowedFileTypes : {"applescript", "scpt", "scptd", "app"}
lns1.scpt
property theSavePanel_Message : ""
lns1.scpt
property theSavePanel_NameFieldLabel : ""
lns1.scpt
property theSavePanel_Prompt : ""
lns1.scpt
property theSavePanel : missing value
lns1.scpt
property theSavePanel_ReturnCode : missing value
lns1.scpt
tell application id "com.latenightsw.ScriptDebugger8"
lns1.scpt
set theWindow to script window 1
lns1.scpt
set theDoc to current document of theWindow
lns1.scpt
if file spec of theDoc ≠ missing value then error "Skript ist bereits gespeichert"
lns1.scpt
set theSource to source text
lns1.scpt
set theLines to paragraphs of theSource
lns1.scpt
set theLine to item 1 of theLines
lns1.scpt
set theLineWithoutKey to (characters 10 thru -1 in theLine) as string
lns1.scpt
if theLineWithoutKey contains " - " then
lns1.scpt
set thePrefixDelimiterOffset to offset of " - " in theLineWithoutKey
lns1.scpt
set thePrefix to characters 1 thru (thePrefixDelimiterOffset - 1) in theLineWithoutKey as string
lns1.scpt
set theName to (characters (thePrefixDelimiterOffset + 3) thru -1 in theLineWithoutKey) as string
lns1.scpt
set thePrefix to missing value
lns1.scpt
set theName to theLineWithoutKey
lns1.scpt
if the error_number is not -128 then display alert "Script Debugger" message error_message as warning
lns1.scpt
set theDirectoryPath to theDirectoryPath_Default -- testing
lns1.scpt
set theName to "A name" -- testing
lns1.scpt
set {thePath, theExtension} to my saveFile(theDirectoryPath, theName, theAllowedFileTypes)
lns1.scpt
if theExtension = "applescript" then
lns1.scpt
save as text script in POSIX file thePath
lns1.scpt
else if theExtension = "scpt" then
lns1.scpt
save as compiled script in POSIX file thePath
lns1.scpt
else if theExtension = "scptd" then
lns1.scpt
save as bundled compiled script in POSIX file thePath
lns1.scpt
else if theExtension = "app" then
lns1.scpt
save as script application in POSIX file thePath
lns1.scpt
on saveFile(theDirectoryPath_Default, theSuggestedFileName, theAllowedFileTypes)
lns1.scpt
if current application's AEInteractWithUser(-1, missing value, missing value) ≠ 0 then error number -1713 from current application
lns1.scpt
set theDefaultPathURL to current application's |NSURL|'s fileURLWithPath:theDirectoryPath_Default
lns1.scpt
set theSavePanelRecord to {allowedFileTypes:theAllowedFileTypes, allowsOtherFileTypes:false, canCreateDirectories:true, directoryURL:theDefaultPathURL, extensionHidden:false, message:theSavePanel_Message, nameFieldLabel:theSavePanel_NameFieldLabel, nameFieldStringValue:theSuggestedFileName, prompt:theSavePanel_Prompt, showsTagField:false}
lns1.scpt
its performSelectorOnMainThread:"displaySavePanel:" withObject:theSavePanelRecord waitUntilDone:true
lns1.scpt
if theSavePanel_ReturnCode is (current application's NSFileHandlingPanelCancelButton) then error number -128
lns1.scpt
set thePath to (theSavePanel's |URL|()'s |path|())
lns1.scpt
set theExtension to thePath's pathExtension()
lns1.scpt
return {thePath as string, theExtension as string}
lns1.scpt
if the error_number is not -128 then display alert "Error: Handler \"saveFile\"" message error_message as warning
lns1.scpt
end saveFile
lns1.scpt
on displaySavePanel:theSavePanelRecord
lns1.scpt
if (current application's NSThread's isMainThread()) = false then error "Handler kann nur auf Main Thread genutzt werden." from current application
lns1.scpt
set theSavePanel to current application's NSSavePanel's savePanel()
lns1.scpt
tell theSavePanel
lns1.scpt
its setAllowedFileTypes:(allowedFileTypes of theSavePanelRecord)
lns1.scpt
its setAllowsOtherFileTypes:(allowsOtherFileTypes of theSavePanelRecord)
lns1.scpt
its setCanCreateDirectories:(canCreateDirectories of theSavePanelRecord)
lns1.scpt
its setDirectoryURL:(directoryURL of theSavePanelRecord)
lns1.scpt
its setExtensionHidden:(extensionHidden of theSavePanelRecord)
lns1.scpt
its setMessage:(message of theSavePanelRecord)
lns1.scpt
its setNameFieldLabel:(nameFieldLabel of theSavePanelRecord)
lns1.scpt
its setNameFieldStringValue:(nameFieldStringValue of theSavePanelRecord)
lns1.scpt
its setPrompt:(prompt of theSavePanelRecord)
lns1.scpt
its setShowsTagField:(showsTagField of theSavePanelRecord)
lns1.scpt
set my theSavePanel_ReturnCode to theSavePanel's runModal()
lns1.scpt
if the error_number is not -128 then display alert "Error: Handler \"displaySavePanel\"" message error_message as warning
lns1.scpt
end displaySavePanel:
lns1.scpt
use framework "AppKit" -- for image stuff
lns1.scpt
set posixPath to POSIX path of (item 1 of finderSelectionList)
lns1.scpt
set bitmapImage to current application's NSBitmapImageRep's imageRepWithContentsOfFile:posixPath
lns1.scpt
set theAlpha to (bitmapImage's valueForKey:"hasAlpha") as boolean
lns1.scpt