Best strategy to make sure User runs procedure in a New/Clean experiment?

I've written several procedures in Igor which import external data, process it and produce layouts containing a summary of the results. I try to write these procedures in a way that if a User presses cancel or something else goes wrong, they can be run again. Sometimes though this isn't possible and if data folders or waves already exist then the procedure doesn't work as expected or at least the experiment is cluttered.

I'm thinking of ways to insert a checking function to see if the experiment is new (or clean). My best idea so far is to count data folders in root: and waves in root: and to abort if either value is > 0. Does anyone else have any other ideas? I figured others may have come across this situation. Any advice/tips appreciated.
In some situations I have written a function that mines the time stamp (WaveInfo -> MODTIME, or modDate) to check whether particular data had been updated after a particular event. I did this with a GUI update function (that would normally take a few seconds to run) to bypass this update if it was not required (i.e. data had not changed). The update function (if run) would effectively wipe the old (GUI-related) waves and recreate them from the existing data. Maybe a similar approach could be useful for you.
Thanks Kurt, that's a good idea. I will definitely use that for one of my projects. Cheers
A recommended convention is to generate a root:Packages:MyPackage folder to hold stuff associated with "packages". When the package folder does not exist, the experiment is "clean". Otherwise, store a global in the package folder and update it from within your function calls as a way to leave a breadcrumb trail.

--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
sjr51 wrote:
I've written several procedures in Igor which import external data, process it and produce layouts containing a summary of the results. I try to write these procedures in a way that if a User presses cancel or something else goes wrong, they can be run again. Sometimes though this isn't possible and if data folders or waves already exist then the procedure doesn't work as expected or at least the experiment is cluttered.

I'm thinking of ways to insert a checking function to see if the experiment is new (or clean). My best idea so far is to count data folders in root: and waves in root: and to abort if either value is > 0. Does anyone else have any other ideas? I figured others may have come across this situation. Any advice/tips appreciated.


You can directly disregard the heuristic checks, whether an experiment is "clean" or not, by loading a blank experiment template upon your chosen condition like so:
string s_exp_template = ":relative:path:ondisk:blank_exp.pxt"
execute/p/q "NEWEXPERIMENT " //suppress save experiment dialog
execute/p/q "LOADFILE"+ " " + s_exp_template


Where, :relative_path:ondisk:blank_exp.pxt (if on windows),
will be in (for example): c:\program files\wavemetrics\igor pro folder\relative_path\ondisk\blank_exp.pxt

Depending on your use-case issuing execute/p/q "NEWEXPERIMENT " maybe enough.

For more info: displayhelptopic "Operation Queue"

best,
_sk