"Brian Mathis" <[EMAIL PROTECTED]> wrote in message
news:14034@palm-dev-forum...
> My question becomes relevant in the case that
> 1. My app is running, and
> 2. an Info form is being displayed.
>
> When the info form is being displayed, a database is open.  If the user
> happens to be receiving a database with the same name as the one that's
> open, this will likely cause an error when the new database tries to be
> written (if I'm wrong about this, enlighten me).  Also, if the database
> coming in has other information that is different than the old one, that
> will be incorrect on the info form as well.

Most apps beam records rather than entire databases, but what you're doing
is not unusual. I assume you're using ExgDBRead/Write. These routines
provide a mechanism for dealing with overwriting an existing database. You
do want to close the old one before overwriting it though.

> I would like to get around this by simply closing the info form just
> before the app starts to receive.  This will result in the database being
> closed and the display returning to the main form.

You could just close the database, but not switch forms. Then re-open the
database when you're done (or leave it NULL and let the app can reopen it
later). The code would look something like this:

handling sysAppLaunchCmdExgReceiveData:
    if you have access to globals
        if the database is open
            close the database
            set the openRef to null (for safety)
            set a flag so we know we need to reopen the database
    read in the database, overwriting if necessary
    if the flag was set
        open the new database (putting the openRef in the same global)

> I should probably close the database after I've drawn all the info to the
info form.

You could avoid keeping the database open, but remember that a beam can come
in at any time. (Well, not quite, but at least any time you go around the
event loop.) You might have the database open. You should probably just
close it when you receive.

This brings to mind the problem we had with the Agenda view. Be careful if
you open another app's database for write. The other app won't know you have
it open, so it won't close it when it receives a beam. When it tries to
write to the database it'll fail. The solution: always close the database
before going around the event loop. I don't think this applies to you, but
it's interesting. :)
--
Danny Epstein
OS Engineer, Palm Inc.


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to