[Thread Prev][Thread Next][Index]

Re: control flow



Hi Mark,
This seems to be a case where the command parser
has trouble with the compound expression.  Ferret
starts looking for a THEN where you have the OR in
this command.

yes? if `ivar eq "Temp"` OR `ivar eq "Salt"` then
 !-> if  1 or `ivar eq "Salt"` then
 **ERROR: command syntax: IF without THEN
          if  1 or `ivar eq "Salt"` then
 **ERROR: stack underflow

A simple way around this is to define a new variable with
the compound conditional, and remember to use grave
accents around it so it is evaluated in the IF-THEN-ELSE
command.

let ivar = "Temp"
let g =  `ivar eq "Temp"` or `ivar eq "Salt"`
if `g` then
   say "hello"
else
   say "there"
endif


Ansley Manke

Mark.Collier@csiro.au wrote:

> It is possible to test in the following way:
>
> let ivar="Temp"
>
> if `ivar eq "Temp"` then
> say "hello"
> elif `ivar eq "Salt"` then
> say "there"
> else
> say "you"
> endif
>
> However, is it possible to test with compound arguments, for example:
>
> if `ivar eq "Temp"` OR `ivar eq "Salt"` then
> say "hello"
> else
> say "there"
> endif
>
> Anyone have a solution? I've tried a number of combinations, including using ()'s without success.
>
> Many thanks,
> Mark.

--
Ansley Manke  Pacific Marine Environmental Laboratory  Seattle WA




[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement