using waveexists and creating the non-existant wave
daggaz
wave testwave //have to declare it or waveexists wont work
if (waveexists(testwave) == 0 )
...make/o/d/n=1 testwave
endif
if (waveexists(testwave) == 0 )
...make/o/d/n=1 testwave
endif
I cant seem to do this, as the two wave references are overlapping. Is there a way?
Also just in general, some way to check for the existence of data before running a section of a user defined function. Purpose being that said function will create certain data on the first running, but subsequent passes would then skip this part. The check has to be permanent after the function has finished running, which is why I tried with a wave here..
if (waveexists(testwave) == 0 )
...make/o/d/n=1 testwave
endif
May 9, 2013 at 03:33 am - Permalink
May 9, 2013 at 03:35 am - Permalink
if (waveexists(testwave) == 0 )
make/o/d/n=1 testwave
endif
May 9, 2013 at 03:43 am - Permalink
make /o/d/n=(1) testwave
As Howard points out below, this is not correct. Parentheses are needed if the argument is a variable.
Egregious display of ignorance expurgated.
May 9, 2013 at 12:50 pm - Permalink
Or you could do something like this
if (waveexists(tempwave) ==0)
make/o/d/n=1 testwave
endif
If the wave reference is made with respect to a string name, they don't have to have the same flags. This seems odd to me but it gets around the problem.
May 9, 2013 at 06:24 am - Permalink
which gives you two wave references in the function - one with /D and one without - thus the compile error "Inconsistent type for wave reference".
The automatic wave reference is created only if the argument to Make is a simple name, not if it uses a $ or a path (:testwave).
Here is how I would do it:
Wave/Z w=testwave // Reference to testwave in current data folder
if (waveexists(w) == 0)
Print "Making testwave"
Make/O/D/N=1 testwave
else
Print "testwave already existed"
endif
Wave w = testwave
Print NameOfWave(w)
End
This is true only if the parameter to /N is a variable, not if it is a literal number.
May 9, 2013 at 08:56 am - Permalink
May 9, 2013 at 12:46 pm - Permalink