I'm building an ASstudio app. using database events to store my data, and have run into a problem when calling a "on selection changed" handler.
Im basically just trying to keep the data in sync with the selection of the table view and my text view.
When the handler is called I get a DBevents error.
Code is below. Any help would be greatly appreciated. Thanks, -E
property scriptSource : "My Scripts"
property theDBPath : "/Users/erichpearson/Documents/Databases/myDatabase.dbev"
on awake from nib theObject
tell application "Database Events"
open database theDBPath
tell database "myDatabase"
set n to name of every record
set defaultRec to record 1
tell record 1
set defaultContents to value of field "Script Content"
set defaultPath to value of field "Script Location"
end tell
end tell
close database "myDatabase"
quit
end tell
set content of table view 1 of scroll view 1 of split view 1 of window 0 to n
set content of text view 1 of scroll view 2 of split view 1 of window 0 to defaultContents
set content of text field 1 of window 0 to defaultPath
end awake from nib
on selection changed theObject
set theSelectedRow to selected data row of table view 1 of scroll view 1 of split view 1 of window 0
set theName to contents of data cell 1 of theSelectedRow as string
--want to get record by name and then get its field values to populate the UI
tell application "Database Events"
close every database
open database theDBPath
tell database "myDatabase"
set theRecord to record theName
tell theRecord
set theContents to value of field "Script Content"
set theScriptPath to value of field "Script Location"
end tell
close database "myDatabase"
display dialog theScriptPath
end tell
end tell
end selection changed
=