I keep having an error condition in the IDE for a stack that access a Database.
When the program is on a card that access a DB record, I have a function in the on CloseCard handler to SAVE the record that is active when the user leaves the card.
If I EXIT the IDE when I'm on one of these cards I get the following error condition that lock the program.
Stack "DatabaseControl" execution error at line n/a
(External Handler: exception) near 'revdberr, invalid connection id'
And the window display the SAVE function at the following code:
put revdb_execute( gConID, tSQL ) into tTemp
I've put the following code in the on CloseStack handler to attempt to delay until the card is closed, but keep getting the problem.
on closeStack
wait for 400 millisecond with messages
if gConID is an Integer AND gConID > 0 then
get closeDB() -- close the database
put 0 into gConID
end if
stop using stack "DataBaseControl"
close stack me
end closeStack
I believe that LiveCode is closing the database before the card is closed, so the database ID saved in gConID is invalid.
Is there a way to force close the card before closing the database?
Thanks for the help.
Error condition on IDE EXIT
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Error condition on IDE EXIT
Are you sure that gConID is actually declared everywhere it's used? Remember that you need to declare a global in every script that uses it:
global gconID
Also it's possible that some other global is named gConID, maybe that is the problem (a so called name conflict). I'd suggest to check manually what your connection number is supposed to be after you created the connection, then again check if that number is still the same at the end, for example like this:
Finally, remember that closeStack is sent while the stack is closing, and not before. So maybe try using "closeStackRequest" instead.
It's also possible that the IDE is interfering somehow weirdly with your code, as it tends to catch closeStack and not always passes it on. So it might be possible that your code works fine in a standalone, just not in the IDE.
global gconID
Also it's possible that some other global is named gConID, maybe that is the problem (a so called name conflict). I'd suggest to check manually what your connection number is supposed to be after you created the connection, then again check if that number is still the same at the end, for example like this:
Code: Select all
--some button
global gConID
on mouseUp
answer file ""
put revOpenDatabase("sqlite",it, , , ) into gConID
put gConID
end mouseUp
Code: Select all
--card script
global gConID
on closeCard
put gConID
end closeCard
It's also possible that the IDE is interfering somehow weirdly with your code, as it tends to catch closeStack and not always passes it on. So it might be possible that your code works fine in a standalone, just not in the IDE.
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
-
- Posts: 87
- Joined: Tue Nov 13, 2007 6:40 pm
Re: Error condition on IDE EXIT
I have verified that the global gConID which saves the DB ID is properly defined. All the database function work fine during normal program operation.
When the user closes the Stack by selecting a button in the application to issue:
send "closeStack" to this Stack
The IDE closes the stack without an error.
HOWEVER when you select EXIT the IDE brings up the stack again and asks if you want to SAVE the changes. If you say yes it will HANG at the revdb_execute(gConID, tSQL) statement again.
ERROR: (Error in function handler) near "revOKTarget", char 11
IF you select the "X" on the window to close the application, it asks then to SAVE the changes at that time and the IDE will EXIT without an error. So if you X out the window it SAVES and closes the stack.
If I EXIT the Stack and remove it from memory then IDE EXIT works without an error.
On EXIT the IDE is closing the card, which causes the save data function to be called to save the data to the DB, but the IDE forces the DB handler functions to EXIT before the card closes.
I expect this won't be a problem when the application is running as a StandAlone, however it is a IDE irritation.
When the user closes the Stack by selecting a button in the application to issue:
send "closeStack" to this Stack
The IDE closes the stack without an error.
HOWEVER when you select EXIT the IDE brings up the stack again and asks if you want to SAVE the changes. If you say yes it will HANG at the revdb_execute(gConID, tSQL) statement again.
ERROR: (Error in function handler) near "revOKTarget", char 11
IF you select the "X" on the window to close the application, it asks then to SAVE the changes at that time and the IDE will EXIT without an error. So if you X out the window it SAVES and closes the stack.
If I EXIT the Stack and remove it from memory then IDE EXIT works without an error.
On EXIT the IDE is closing the card, which causes the save data function to be called to save the data to the DB, but the IDE forces the DB handler functions to EXIT before the card closes.
I expect this won't be a problem when the application is running as a StandAlone, however it is a IDE irritation.
Re: Error condition on IDE EXIT
Ah i see now. Yes, the IDE sometimes does weird things. One way to test that is to select "suspend development tools" from the development menu. If you do that, the ide won't ask you to save your stack, and therefore won't call your closestack or closecard scripts unwanted.
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode