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

Home » Public Forums » archive » Easy question?
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: easy question [message #45749 is a reply to message #16325] Fri, 07 October 2005 12:58 Go to previous messageGo to previous message
Richard French is currently offline  Richard French
Messages: 173
Registered: December 2000
Senior Member
You can also dispense with the begin and endif/endelse entries as follows:



pro mydemo,arg

if arg eq 1 then print,"one" $
else if arg eq 2 then print,"two" $
else print, "many
end

mydemo,1
mydemo,2
mydemo,3
End


On 10/6/05 10:48 PM, in article di4nlo$2550$1@agate.berkeley.edu, "Marshall
Perrin" <mperrin+news@cymric.berkeley.edu> wrote:

>
> Both Michael and Haje are correct that one can use a case statement
> for this sort of thing. But IDL handles a series of if statements just
> fine, too:
>
> pro demo, arg
>
> if arg eq 1 then begin
> print,"one"
> endif else if arg eq 2 then begin
> print,"two"
> endif else begin
> print, "many"
> endelse
>
> end
>
> This requires typing a lot more characters than the case version,
> but I think it can sometimes make the program logic a bit clearer.
> Either way works, so feel free to use whichever idiom you feel more
> comfortable with.
>
> - Marshall
>
>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Five days mean values
Next Topic: Re: how to use map_set in object graphics programming

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

Current Time: Fri Oct 17 21:16:46 PDT 2025

Total time taken to generate the page: 1.20004 seconds