7. Initiating FileFlex Operations
FileFlex operates as a self-contained little world within the host environment.
Each time you make a call to FileFlex, you're rapidly loading and unloading
the FileFlex engine. But since FileFlex needs to maintain an awareness of
all the database information between calls (when, normally, it would be
completely out of the picture), FileFlex maintains it's own internal memory
structures and data.
FileFlex also resides as an external code resource to your host environment.
Before you can give FileFlex commands, you need to be able to establish
communications with FileFlex. In most development environments, this is
accomplished by opening a resource or opening an external library. In Director
5, this can be accomplished as easily as dropping the FileFlex Lingo Xtra
into the Xtras folder (see the Installing
FileFlex Files).
We've defined a special standard function for establishing this communication
with FileFlex called DBInitPlatform. This function tells your host environment
where to find FileFlex and how it should be called. It often requires you
to write or customize a few lines in your native environment's language
to open the resource. Details on defining DBInitPlatform
are described in the FileFlex API Reference.
Once you've established communications, FileFlex must be initialized the
first time it's used and "turned off" when you're finished. When
you tell FileFlex to initialize itself, it allocates all the memory data
structures it'll need for your database session. You'll need to call DBOpenSession
for this to happen.
Warning: FileFlex is NOT reentrant. You may only call DBOpenSession
once. Then, you can't call it again unless you've turned FileFlex off by
calling DBCloseSession. Attempting to do repeated DBOpenSession or DBCloseSession
calls without it's mate will result in very bad things happening.
After you are done using FileFlex, you should clean up your environment
by releasing memory used for buffers. To do this, put the following call
into the handler called when exiting your movie or project. (It may be placed
elsewhere, but this is the most logical place for its use.)
put DBCloseSession() into dbResult
This will free all the data structures in use by the FileFlex engine. Failure
to do this may cause all sorts of unpleasant problems.
Finally, call DBClosePlatform to deallocate the external resource and turn
off communications to FileFlex.
[Previous Chapter] [Table of Contents] [Next Chapter]
Copyright (c) 1996 David Gewirtz under license to Component Software Corp.
All rights reserved worldwide.