comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » AND statements
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: AND statements [message #14571 is a reply to message #14504] Mon, 08 March 1999 00:00 Go to previous messageGo to previous message
Martin Schultz is currently offline  Martin Schultz
Messages: 515
Registered: August 1997
Senior Member
Stein Vidar Hagfors Haugan wrote:
>
>
> True. The "problem" is when you want to write this up into
> a short and concise test with an ELSE part, you'll have to
> repeat the ELSE branch:
>
> IF NOT (A EQ 0) THEN IF B/A GT 5 THEN <SOMETHING> $
> ELSE <SOMETHING_ELSE> $
> ELSE <SOMETHING_ELSE>
>
> (Where the second SOMETHING_ELSE is the same as the first one)
>
> [...]

in short this is the same as
IF E1 THEN ( IF E2 THEN A ELSE B ) ELSE C

I don't think there are that many cases where B is really the same as C.
If so,
I find it often in error checking (is there a filename? is it empty?
etc.). In
these cases, it is often useful to "invert" the above to e.g.

IF NOT E1 THEN RETURN
IF E2 THEN A ELSE B

Shame on me(?), but sometimes I even think of and use GOTO statements in
similar
constructs. For skipping large convoluted IF THEN ELSE IF THEN ELSE
ENDIF IF ...
blocks, they are sometimes much more readable.

But it is true that I have often wished IDL had the abbreviated IF
clause. In my experience this is so common in modern computer languages
that it is rather dangerous *not* to have it available.

Regards,
Martin.

--
------------------------------------------------------------ -------
Dr. Martin Schultz
Department for Engineering&Applied Sciences, Harvard University
109 Pierce Hall, 29 Oxford St., Cambridge, MA-02138, USA

phone: (617)-496-8318
fax : (617)-495-4551

e-mail: mgs@io.harvard.edu
Internet-homepage: http://www-as.harvard.edu/people/staff/mgs/
------------------------------------------------------------ -------
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Drag-Drop Possible in IDL5.2 ??
Next Topic: Re: XResources and menu mnemonics

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 12:48:39 PDT 2025

Total time taken to generate the page: 0.87813 seconds