National Oceanic and
Atmospheric Administration
United States Department of Commerce

Journal file conditionals based on arguments.

Journal file conditionals based on arguments.

Question:

Is it possible to have a GO script with a conditional based on the value of an argument?

Explanation:

The main relevant documentation is in the Ferret Users Guide, see "GO, arguments" in the index.

Also relevant is thedocumentation on the IF-THEN-ELSE structure

The same approach that works on arguments also applies to symbol substitution.

Solution:

Here's an example jnl 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? cancel 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

 


Last modified: Apr 22, 2004