I have built my first applescript application in XCode, using a tutorial I found online, which addresses using TableView.
Here is the script. I am having a hard time debugging it.
Can someone recommend an applescript editor?
Could someone copy and paste this into the Editor and see what the problem is? It may not work with the Editor, though, as it uses instances in XCode.
on awake from nib theObject set theDataSource to make new data source at end of data sources with properties {name: "Account Data"} tell theDataSource make new data column at end of data columns with properties {name: "Account Name"} make new data column at end of data columns with properties {name: "Account Status"} end tell set data source of theObject to theDataSource end awake from nib
on refreshAccountListing() tell application "Mail" set theAccountNameList to name of every account set theAccountStatusList to enabled of every account end tell
tell data source "Account Data" set update views to false delete every data row repeat with a from 1 to length of theAccountNameList set theRow to make new data row at end of data rows
tell theRow set contents of data cell "Account Name" to item a of theAccountNameList if item a of theAccountStatusList = true then set theAccountStatus to "Enabled" else set theAccountStatus to "Disabled" end if
set contents of data cell "Account Status" to theAccountStatus end tell
end repeat
set update views to true
end tell
end refreshAccountListing
on launched theObject refreshAccountListing() set visible of window "Main Window" to true end launched
on toggleAccounts() set theSelectRows to selected data rows of table view "Account List" of scroll view "Account List" of window "Main Window" repeat with a from 1 to length of theSelectedRows set theRow to item a of theSelectedRows
tell theRow set theAccountName to contents of data cell "Account Name" set theAccountStatus to contents of data cell "Account Status"
if theAccountStatus = "Enabled" then set theNewAccountStatus to false else set theNewAccountStatus to trus end if
tell application "Mail" set enabled of account theAccountName to theNewAccountStatus end tell
end tell
end repeat
refreshAccountListing()
end toggleAccounts
on clicked theObject if name of theObject = "Toggle" then toggleAccounts() else quit end if end clicked
|