[Thread Prev][Thread Next][Index]

Re: Negating aymbols in conditionals



Hi David,

This illustrates a symbol manipulation technique that has the effect of
a NOT operand.

 yes? define symbol condition = false
 yes? if ($condition) then (say do it) endif
  !-> if false then (say do it) endif
 yes? if ($condition"|true>0|false>1") then (say do it) endif
  !-> if 1 then (say do it) endif
 do it
 yes? quit

An alternative approach using immediate mode expressions:

 yes? define symbol condition = 0
 yes? if `($condition) NE 1` then (say do it) endif
  !-> if 1 then (say do it) endif
 do it

Not as clean as "!($condition)", I grant you, but serviceable.

	Happy Ferreting - steve

================================================================

David Oxilia wrote:
> 
> Hello all,
> 
> I'd like to use a logical NOT in a an IF statement which uses
> a symbol as the conditional. Common use of symbols with IF
> statements goes as:
> 
> if ($condition) then
>   do this
> endif
> 
> Is there a way to do something like:
> 
> if (!$condition) then
>   do this
> endif
> 
> where (!$conditon) stands for the negated evaluation of the
> symbol ($condition).
> 
> I realize that it is trivial to swap the flag name and use
> the ($condition) form rather than the (!$condition) form
> but I'd still like to know whether there is a NOT in ferret.
> 
> thanks,
> 
> David.
> 
> *~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
> David Oxilia                    Tel: (541) 737-2368
> COAS:Oregon State University    Fax: (541) 737-2064
> Ocean Admin. Bldg. 104          WWW: http://www.oce.orst.edu/po
> Corvallis, OR 97331-5503        Email: oxilia@kundun.oce.orst.edu
> *~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*

-- 

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


[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement