Arto:
I assume you know the names of the channels you wish to change.
In that case, you would use GX code such as the following:
// --- Get current database ---
EData = Current_EDB();
Data = Lock_EDB(EData);
// --- Get the channel you want to alter ---
if (iExistSymb_DB(Data,"OldChannelName",DB_SYMB_CHAN)){
Ch = FindSymb_DB(Data,"OldChannelName",DB_SYMB_CHAN);
// --- Lock it ---
LockSymb_DB(Data,Ch,DB_LOCK_READWRITE,DB_WAIT_INFINITY);
// --- Change its name ---
SetChanName_DB( Data, Ch, "NewChannelName");
// --- Unlock it ---
UnLockSymb_DB(Data,Ch);
}
You could even re-write the above as a macro and call it for all the sets of
"old" and "new" names you are considering:
// --- Put this after your #include statements ....
#define CHANGE_NAME(A,B) \
if (iExistSymb_DB(Data,A,DB_SYMB_CHAN)) { \
Ch = FindSymb_DB(Data,A,DB_SYMB_CHAN); \
LockSymb_DB(Data,Ch,DB_LOCK_READWRITE,DB_WAIT_INFINITY); \
SetChanName_DB(Data,Ch,B); \
UnLockSymb_DB(Data,Ch); \
}
... and in the code use the following:
// --- Get current database ---
EData = Current_EDB();
Data = Lock_EDB(EData);
// --- Change names of channels ---
CHANGE_NAME("OldName1","NewName1")
CHANGE_NAME("OldName2","NewName2")
CHANGE_NAME("OldName3","NewName3")
... etc...
(Be sure to include in your variable definitions the variables used in the
macro, e.g.:
DB_SYMB Ch;
Stephen Cheesman
Geosoft Inc.
-----Original Message-----
From: Arto Korpisalo [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 25, 2001 12:58 AM
To: [EMAIL PROTECTED]
Subject: [gxnet]: To change header name in the database
Hi all!
I have made many gx_files where I use default names for the
channels. Of cource x and y are allways the same but the data
channel names may be very different. Now when I import the
xyz-data into the database the headers may be whatever.
I can change them now in the database window by clicking with
the mouse the header and edit but that is not what I want to do.
Because there is allways somebody who doesn't remember to
change them so I want to add some necessary raws to gx_file
and so he can't miss the change. But I have a problem how to
get control on the headers which I want to change.
Can somebody give me some ideas how to do the task?
Regards Arto Korpisalo
_______________________________________________________
More mailing list info http://www.geosoft.com/support/listserv/index.html
List Archive http://www.mail-archive.com/[email protected]
_______________________________________________________
More mailing list info http://www.geosoft.com/support/listserv/index.html
List Archive http://www.mail-archive.com/[email protected]