David Wang wrote:
Yes, true. In a future version we'll add a symbol that lets the user get the total number of open datasets though. We've been working on adding more of this kind of thing, to let you access information that Ferret knows but doesn't make available to the programmer to use in scripts.Thank you, Ansley.It's a nice workaround, providing I don't change the current dataset with SET DATA.
You could also do something of the sort yourself, by setting up a symbol that you increment every time you open a dataset, which might be feasible if you always use a script to open the dataset. This kind of thing, having small "utility" scripts that do operations, are useful when a set of scripts will be used over and over to do similar things but with different inputs.
yes? GO open_a_dset datatsetname.ncand then open_a_dset.jnl opens the dataset, maybe checks to see that this was successful, and increments the counter. This particular script would let the calling script continue if one dataset was unavailable (something you might NOT want to do!)
! open_a_dset.jnlSET MODE ignore_error USE $1
IF ($ferret_last_error"0|*>1") EQ 1` THENECHO "error opening dataset" $1 !Ferret will have issued error msgs, too...
EXIT/SCRIPT ENDIF CANCEL MODE ignore_errorDEFINE SYMBOL n_open_dsets = ($n_open_dsets"0") + 1 EXIT
Ansley
David Ansley Manke wrote:Hi David,There isn't such a symbol, per se. (That's a good idea though). However you can get this information if you know a variable in the last dataset opened, by using `var,RETURN=dsetnum`yes? use etopo120 yes? use etopo60 yes? use etopo20 yes? let dsetnum = `rose,return=dsetnum` !-> DEFINE VARIABLE dsetnum = 3 David Wang wrote:Hi Ferreters,I wonder if there is any system symbol (or means) keeping track of the number of opened datasets in the current session. I'd like loop around all datasets with the command:repeat/name=m/range=1:`number_of_datasets` let/data=`m` v2 = v1[t=@ave] without manually counting and specifying the number of datasets. Thanks, David