[Thread Prev][Thread Next][Index]
[ferret_users] How can I check existence of a variable
Hi all,
In 2005, someone asks how to check if a variable exists.
Read
http://www.pmel.noaa.gov/maillists/tmap/ferret_users/fu_2005/msg00828.html
I have tried to use return value but the error message is not trappable
yes? use levitus_climatology.cdf
yes? def sym isexist=`temp,return=dsetnum`
!-> def sym isexist=1
yes? def sym isexist=`abcd,return=dsetnum`
**ERROR: variable unknown or not in data set: ABCD
So is there a way to improve return value mechanism to trap the error
message
and get a return value set to "ERROR". It would be easy then to test it with
a simple test:
check.jnl
def sym isexist=`($01),return=dsetnum`
if `"($isexist)" eq "ERROR"` then
say "($01) does not exist"
elif
say "($01) exists"
fi
Thanks
Patrick
[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce /
NOAA /
OAR /
PMEL /
TMAP
Privacy Policy | Disclaimer | Accessibility Statement