|
From: Ethan A M. <merritt@u.washington.edu> - 2019-06-06 19:39:10
|
On Thursday, June 6, 2019 11:30:40 AM PDT Achim Gratz wrote:
> Ethan Merritt (UW) writes:
> > * CHANGE clear STATS_* variables before performing analysis
>
> It took me a while to relaize, but that particular change killed on of
> my scripts. That is using data that doesn't always exist, so I have to
> test for that like this:
>
> --8<---------------cut here---------------start------------->8---
> STATS_records=0
> stats [24*sr:24*sq] data using ($4==10?t($1):1/0):($2) nooutput
> TEST=STATS_records>0
> --8<---------------cut here---------------end--------------->8---
>
> That gives you a warning from stats, but you could then skip additional
> code using the non-existing data (that would error out) based on the
> result in TEST.
>
> That no longer works since you're now getting an error (terminating the
> script) at the last line. Note that you can't do something like
> exist(STATS_record) either like one could reasonably expect to work.
> Any workarounds?
>
>
> Regards,
> Achim.
I may not understand the required test. The following works for me:
datafile = "whatever"
if (exists("STATS_records")) { print 'got it already' }
else { stats datafile }
I would probably use an explicit name rather than STATS:
if (exists("MYDAT_records")) { print 'already did MYDATA' }
else { stats datafile name "MYDAT" }
show var MYDAT
Is the problem that STATS_records might exist for reasons other
than having run a previous STATS command? That was exactly
the sort of confusion that the change you mention was intended
to prevent.
Ethan
Ethan
|