Get all waves in all data folders.

Dear all,

I am wondering what is the appropriate way to get all variables in all data folders through an XOP. Right now the only way that I understand something like this could be done is to traverse through the datafolder tree and issue WaveList as traversing.

Further, is there a public hook that will get called after a numeric or string variable, wave, or datafolder is created, i.e. something like AfterCompiledHook but for data, AfterDataAddedHook(?) or something like that?

Thanks!

best,
_sk
WaveList will give you waves, not variables. From an XOP, you can use GetIndexedDataFolderObject to get all objects of a type in a single data folder, and GetIndexedChildDataFolder to iterate through child data folders. Note that if you have a lot of objects in a data folder, this won't be very efficient, because the list of objects needs to be walked over starting from the first object each time you call one of those functions.

I don't believe there's any hook that matches what you're looking for. Even the Igor 7 data browser (which is built-in) has to go to somewhat great lengths to get this information.
VariableList, page 281 XOP manual, is the function you are looking for I guess. You still have to traverse the datafolder tree as it works on CDF though. May I ask what you want to do with this list?

Can dependency formulas help in getting notified? I've only ever used them for getting notified if a wave changes, but maybe the same is also possible for getting a notifcation on a datafolder content change.

Alternatively if the check is quick you might be able to cheat and do the check regularly in the IDLE_EVENT.
aclight wrote:
I don't believe there's any hook that matches what you're looking for. Even the Igor 7 data browser (which is built-in) has to go to somewhat great lengths to get this information.


Thanks. I don't know how Igor is written, but there has to be heap allocation for all of these variables (read, generic code, as in: variables, strings, waves, datafolders, functions, operations). The moment of allocation may be a good point to put a hook. Another good point would be on refcount clean or general garbage collection. Admittedly, I don't have an idea how other platforms do it (i.e. matlab).

thomas_braun wrote:
Alternatively if the check is quick you might be able to cheat and do the check regularly in the IDLE_EVENT.


This sounds interesting. Thanks for mentioning it. Otherwise, I am just trying to collect the data of a folder and sub-datafolders for an experiment and check when it updates.

best,
_sk

Otherwise, I am just trying to collect the data of a folder and sub-datafolders for an experiment and check when it updates.


Is it your code which updates the experiment data? If yes, the easiest thing would be to just call a XOP function passing the folder with new data, or?

thomas_braun wrote:
Is it your code which updates the experiment data? If yes, the easiest thing would be to just call a XOP function passing the folder with new data, or?


I wanted to be able to combine the changes to a datafolder made in Igor with the changes made in an XOP. That's why I wanted to know the state of the datafolder and the data in Igor and expose this state in the XOP. But with no way of knowing when data updates/gets created it will be pretty hard.
_sk wrote:

I wanted to be able to combine the changes to a datafolder made in Igor with the changes made in an XOP. That's why I wanted to know the state of the datafolder and the data in Igor and expose this state in the XOP. But with no way of knowing when data updates/gets created it will be pretty hard.

There's no documented way for an XOP to monitor whether the contents of a data folder have changed.

On a related point, if you happen to figure out a way to do this, make sure that you store a data folder ID number, not a DataFolderHandle. See GetDataFolderByIDNumber and GetDataFolderIDNumber in the XOP toolkit.
aclight wrote:
There's no documented way for an XOP to monitor whether the contents of a data folder have changed.


I figured out how to do it. Thanks for the help ;-)
_sk wrote:
I figured out how to do it. Thanks for the help ;-)

Sure thing. Just remember that sometimes things are undocumented for a reason!
aclight wrote:
_sk wrote:
I figured out how to do it. Thanks for the help ;-)

Sure thing. Just remember that sometimes things are undocumented for a reason!


What reason do you have in mind for not documenting this feature?

best,
_sk
_sk wrote:
aclight wrote:
_sk wrote:
I figured out how to do it. Thanks for the help ;-)

Sure thing. Just remember that sometimes things are undocumented for a reason!


What reason do you have in mind for not documenting this feature?

It was added specifically for the Data Browser, which prior to Igor 7 was an XOP. Starting with Igor 7, the Data Browser is built in, so there is no need for this and therefore it is entirely untested and unused.

It's quite difficult for XOP code to handle changes to objects correctly and keep themselves updated without crashing or negatively affecting performance (or both). We'd prefer to keep Igor stable and performant vs. supporting a feature like this that has very little demand.
aclight wrote:
_sk wrote:
aclight wrote:
_sk wrote:
I figured out how to do it. Thanks for the help ;-)

Sure thing. Just remember that sometimes things are undocumented for a reason!


What reason do you have in mind for not documenting this feature?

It was added specifically for the Data Browser, which prior to Igor 7 was an XOP. Starting with Igor 7, the Data Browser is built in, so there is no need for this and therefore it is entirely untested and unused.

It's quite difficult for XOP code to handle changes to objects correctly and keep themselves updated without crashing or negatively affecting performance (or both). We'd prefer to keep Igor stable and performant vs. supporting a feature like this that has very little demand.


I understand. Thank you very much for sharing this.

best,
_sk