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

Home » Public Forums » archive » Re: Bug in SWITCH - ELSE: statement?
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: Bug in SWITCH - ELSE: statement? [message #56313 is a reply to message #56308] Thu, 11 October 2007 08:39 Go to previous message
larkn10 is currently offline  larkn10
Messages: 10
Registered: July 2006
Junior Member
Hi Chris,

My understanding of SWITCH is that as soon as one option is true every
subsequent option is executed. The ELSE is the default if there is no
option that works, but it is always executed in a SWITCH statement.

You brought up something interesting (to me anyway.) If you place
the
ELSE earlier in the SWITCH statement, then everything below it is
executed. If you do the same for a CASE statement then only then
ELSE is executed. It never occurred to me until I saw your post
that it was possible to place the ELSE anywhere but at the end.

Anyway, I don't know if this is helpful.




EXAMPLE:
--------

pro switchtest

a = 5

switch a of
else:print,'switchelse'
1:print,'no1'
3:print,'no3'
5:print,'yes5'
6:print,'6'
else:print,'switchelse'
endswitch

case a of
else:print,'caseelse'
1:print,'case1'
5:print,'case5'
endcase

end;switchtest


OUTPUT:
-------
switchelse
no1
no3
yes5
6
switchelse
caseelse



-Larry
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: structure into strcuture
Next Topic: How to make an attribute of the oject visible outside of the class

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

Current Time: Wed Oct 08 17:30:40 PDT 2025

Total time taken to generate the page: 0.00255 seconds