Hi Everyone,
Just a note to add to the use of the NoLoad_EDB function...
The handle returned by this function does not behave in the same way as it
would on one returned
from Load_EDB within the same GX. It was initially designed to "spoof" a
loaded database right before
a call to iRunGX_SYS where the GX loaded expects a database using the
Current_EDB function.
If you want to lock the handle WITHIN the same GX you need to make a call to
Current_EDB before you can
lock the EData handle and use some _DB functions. Also after each Unlock_EDB
and before iRunGX_SYS (where the
GX run used a Current_EDB->Lock_EDB->UnLock_EDB) sequence NoLoad_EDB has to
be called again.
For example:
EData = NoLoad_EDB("database.gdb");
iRunGX_SYS("... // GX contains Current_EDB->Lock_EDB->UnLock_EDB
EData = NoLoad_EDB("database.gdb");
EData = Current_EDB();
Data = Lock_EDB(EData);
...
// Some _DB functions
...
UnLock_EDB(EData);
....
EData = NoLoad_EDB("database.gdb");
iRunGX_SYS("... // GX contains Current_EDB->Lock_EDB->UnLock_EDB
UnLock_EDB(EData);
I will add this to the documentation in edb.gxh
Cheers,
Jacques Beaurain
Geosoft Inc.
Software and services for effective earth science decision-making. Free
Oasis montaj interface with public-domain Data Access Protocol (DAP) for
accessing high-volume spatial data over the Internet available for download
at http://www.geosoft.com/pinfo/free/downloadfree.html
Geosoft Inc.
8th Floor
85 Richmond St. W.
Toronto, Ontario
Canada M5H 2C9
Tel. (416) 369-0111
-----Original Message-----
From: Stephen Cheesman [mailto:[EMAIL PROTECTED]]
Sent: Thursday, December 13, 2001 11:05 PM
To: '[EMAIL PROTECTED]'
Subject: RE: [gxnet]: Database locks
Aaron et al...
I mistakenly included the Destroy_DB function in the list of obsolete or
superceded DB functions.
There are still instances where you might wish to open a database without
loading it into the current workspace using the Open_DB function, which
returns a DB handle. Although GXs automatically destroy created objects when
they exit, it is still good practice to explicitly include the Destroy_XX
function to clean up at the end.
Still, the same point can be made, that in the vast majority of cases these
DB functions have been superceded by EDB equivalents, and should avoided
unless you have a very good reason to use them.
One extra point. If you have GX which needs to operate on a number of
databases, and you don't necessarily want to load them into the current
workspace (which Load_EDB will do), you can use the "NoLoad_EDB" function as
follows:
for(i=0;i<iNDB;i++) {
EData = NoLoad_EDB("database.gdb");
Data = Lock_EDB(EData);
....
....
UnLock_EDB(EData);
}
If the database is already loaded in the workspace, it acts the same as
Load_EDB().
If the database is not loaded, then it will not be loaded, but you have
access to all the DB functions through the EData handle that is returned,
once you call Lock_EDB().
Note that this EData handle itself will only work for a small subset of the
normat EDB functions, because the database is not really in the workspace;
it is only "spoofed". Also, you can only have one "Non-loaded" EDB handle at
a single time. See the edb.gxh include file for more information.
Stephen Cheesman
_______________
Geosoft Inc.
Stephen Cheesman
[EMAIL PROTECTED]
(905) 315-8207
Software and services for effective earth science decision-making.
Free Oasis montaj interface now available at http://www.geosoft.com
-----Original Message-----
From: Stephen Cheesman [mailto:[EMAIL PROTECTED]]
Sent: December 13, 2001 9:18 PM
To: '[EMAIL PROTECTED]'
Subject: RE: [gxnet]: Database locks
Aaron:
You are correct. Current_DB() actually combines the operations:
EData = Current_EDB();
Data = Lock_EDB(EData);
It is actually the old method of getting a locked database, and has been
entirely superceded by the above code in all Geosoft GXs.
You should replace your own usage with the above, and remember to "Unlock"
the database using
UnLock_EDB(EData);
You also should have no need to call Destroy_DB, because "Data" above is an
existing handle, not an object that you create.
In summary, you would use:
EDB EData;
DB Data;
for (i=0; i<3; i++) {
EData = Current_EDB();
Data = Lock_EDB(EData);
....
....
....
UnLock_EDB(EData);
}
The following four functions are effectively obsolete, and, although
supported, should be replaced by the equivalent EDB functions:
// Destroy_DB Closes a Database (obsolete). (No current equivalent)
// Destruct_DB Destructs a Database Object (obsolete). (No current
equivalent)
// Current_DB Returns the Current Database Handle (obsolete).
(Current_EDB, Lock_EDB)
// SetCurrent_DB Sets the current database to this database (obsolete).
(MakeCurrent_EDB, Lock_EDB)
I have just updated the db.gxh file to note this, so other users will not be
mislead...
Stephen Cheesman
_______________
Geosoft Inc.
Stephen Cheesman
[EMAIL PROTECTED]
(905) 315-8207
Software and services for effective earth science decision-making.
Free Oasis montaj interface now available at http://www.geosoft.com
-----Original Message-----
From: skyhunter [mailto:[EMAIL PROTECTED]]
Sent: December 13, 2001 5:31 PM
To: GXNET
Subject: [gxnet]: Database locks
Hi evderyone,
I've just come across something that I don't fully understand. I wrote a GX
and the flow of operation of the relevant portion of the GX is,
for (i=0; i<3; i++) {
Data1 = Current_DB();
....
....
....
Destroy_DB();
}
I kept getting a 'cannot lock database twice error'. To do some tests to
track down the error, I put an Abort_SYS("EXIT") command between the destroy
statement and the closing } of the loop. The GX worked exactly how I
expected it to. I then added another Data=Current_DB() statement after the
existing destroy command and the Abort_SYS command. Upon running, I got the
error again. So my conclusion is that the Current_DB() command locks the
database. Can anyone tell me if this is a correct conclusion? If so, how do
I unlock the database when I do not have an EDB object.
I know the simple thing would just be to create an EDB object, but I
stumbled upon something I don't understand here and I would like to figure
it out if possible.
Aaron Balasch
Sky Hunter Technologies Inc.
Suite 101, 1725 10th Avenue S.W.
Calgary, Alberta T3C 0K1
email: [EMAIL PROTECTED]
phone: 403-228-2175
fax: 403-244-7955
_______________________________________________________
More mailing list info http://www.geosoft.com/support/listserv/index.html
List Archive http://www.mail-archive.com/[email protected]