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 #45756 is a reply to message #16325] Thu, 06 October 2005 11:27 Go to previous message
Michael Wallace is currently offline  Michael Wallace
Messages: 409
Registered: December 2003
Senior Member
You can use a switch or case statement in this case. You can do
something like the following

case 1 of
(x eq 1): print, 'Test 1'
(x eq 2): print, 'Test 2'
(x eq 3): print, 'Test 3'
(x eq 4): print, 'Test 4'
endcase

I'm looking for the first expression that evaluates to true (1). Each
of the expressions are evaluated in turn and the statement associated
with the first expression that evaluates to true is run. If this same
logic were written in a language such as C, it would look like this:

if (x == 1) printf("Test 1\n")
else if (x == 2) printf("Test 2\n")
else if (x == 3) printf("Test 3\n")
else if (x == 4) printf("Test 4\n");

The case construct I used at the top doesn't exist in C or other
languages because there's usually a requirement that the values in the
case or switch must be constants rather than expressions.

Hope that helps,
-Mike
[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: Thu Oct 09 14:59:21 PDT 2025

Total time taken to generate the page: 1.19822 seconds