[Thread Prev][Thread Next][Index]

Re: Conditionals in GO scripts?



Hi Gary,

This is easily done. The main relevant documentation is under arguments
to GO commands
http://ferret.wrc.noaa.gov/Ferret/Documentation/Users_Guide/v44/chapter1.html#arguments
(script)   (from V4.4 Users Guide Index see "arguments")

Also relevant are the release notes on the IF-THEN-ELSE structure at
http://ferret.wrc.noaa.gov/Ferret/Documentation/Release_Notes/v430.html#v43_if_then
... it sounds like you're already using that.

Here's an example:
file "test.jnl":

 if $1"false|yes>true|*>false" then
   say "The user told me to do it"
 else
   say "The user told me not to do it"
 endif

The first "false" is the default value if no argument is supplied. "yes"
translates to "TRUE", all else ("*") translates to "false".

Used as follows:

 yes? canc mode verify
 yes? go test yes
 The user told me to do it
 yes? go test no
   The user told me not to do it
 yes? go test
   The user told me not to do it

Also note that the same approach that works on arguments also applies to
symbols:
http://ferret.wrc.noaa.gov/Ferret/Documentation/Release_Notes/v420/#v42_symbol_replacement

	Happy Ferreting - steve

Gary Strand wrote:
> 
> Perhaps I haven't tried enough (which is often the case!) but I'm wondering if
> it's possible to have a GO script with a conditional based on the value of an
> argument.
> 
> Something like:
> 
> if $3 eq "yz" then
>   plot xxx
>   go land
> else if $3 eq "ab" then
>   plot yyy
>   go land
> end
> 
> Thanks!
> --
> Gary Strand
> strandwg@ucar.edu                              http://www.cgd.ucar.edu/ccr/gary

-- 
Steve Hankin
NOAA/PMEL, 7600 Sand Point Way NE, Seattle, WA 98115-0070
ph. (206) 526-6080 -- FAX (206) 526-6744


[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement