Re: Database Events Problem
Re: Database Events Problem
- Subject: Re: Database Events Problem
- From: Erich Pearson <email@hidden>
- Date: Thu, 26 Jun 2008 20:48:10 -0500
are within the tell block addressed to database "myDatabase" so will
be causing an error. You need to move the "close database ..." line
one level down (same level as your "open database ..." line). You
need to move the "display dialog ..." line outside the tell block
addressed to application "Database Events".
PERFECTO!! That was it. Probably would've taken me forever to figure
it out.
Maybe I should open DB events once at launch, set quit delay to 0 and
then close at end to get rid of some code.
Thank you all for the help!
Erich
On Jun 25, 2008, at 6:47 PM, Philip Buckley wrote:
Your lines
close database "myDatabase"
display dialog theScriptPath
are within the tell block addressed to database "myDatabase" so will
be causing an error. You need to move the "close database ..." line
one level down (same level as your "open database ..." line). You
need to move the "display dialog ..." line outside the tell block
addressed to application "Database Events".
One other small thing ... I would recommend trapping for the user
deselecting in the table view. if there is a row selected and the
user clicks on it again to deselect it, the selection changed
handler will still be called ... and then error because it won't be
able to get data cell 1 of no row. The easiest way to trap for this
is with lines like this ...
set selectedDataRows to get selected data rows of table view ....
if selectedDataRows is {} then
-- handle deselection
else
-- handle selection
end if
Hope that helps
Philip
On Wed 25/06/08 11:31 PM , email@hidden sent:
Hello,
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
---- Message sent via KC WebMail - http://webmail.mistral.net/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Studio mailing list (email@hidden
)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden