Return to Ferret FAQ


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 under Ferret Users Guide, see "GO, arguments" in the index.

Also relevant are the release notes on the IF-THEN-ELSE structure

The same approach that works on arguments also applies to symbols.

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? 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


Last modified: Apr 22, 2004