Re: [Q] if-else statement [message #11706] |
Wed, 06 May 1998 00:00 |
enkpong
Messages: 14 Registered: April 1997
|
Junior Member |
|
|
Jason Li (jyli@redback.gsfc.nasa.gov) wrote:
: Hi,
: In FORTRAN, there is no problem to do:
: IF(test1) THEN
: ...
: ELSEIF(test2) THEN
: ...
: ELSEIF(test3) THEN
: ...
: ELSEIF(test4) THEN
: ...
: ENDIF
: Of course one can replace this with the CASE statement, but it is
: really clumsy in my particular situation.
: As far as I know one can only perform two condition tests (test1 and
: NOT test1) in IDL at one time using IF-ELSE:
: IF(test1) THEN BEGIN
: ...
: ENDIF ELSE
: ...
: ENDELSE
: [Question] How do you do multiple IF-ELSE tests in IDL?
: thanks in advance
: --
: ============================================================ ============
: Jason Y. Li | Tel : (301) 286-1029
: Code 913 | Fax : (301) 286-1759
: NASA Goddard Space Flight Center | www : http://climate.gsfc.nasa.gov
: Greenbelt, MD 20771, USA | email: jyli@climate.gsfc.nasa.gov
: ============================================================ ============
: Beauty of style, harmony, grace and good rhythm depend on simplicity.
You can of course do the same thing in IDL as in Fortran. For example,
if you have four conditions needed to be tested, say TEST1, TEST2, TEST3,
NOT(TEST1,TEST2,TEST3), you may have:
IF (TEST1) THEN BEGIN
....
ENDIF ELSE IF (TEST2) THEN BEGIN
....
ENDIF ELSE IF (TEST3) THEN BEGIN
....
ENDIF ELSE BEGIN
....
ENDELSE
Cheers,
KP.
--
Koon-pong Wong Email : enkpong@en.polyu.edu.hk
Department of Electronic Engineering
The Hong Kong Polytechnic University Phone : (+852) 2766 6201
Hung Hom, Kowloon FAX : (+852) 2362 8439
Hong Kong Office: DE503d
|
|
|