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

Home » Public Forums » archive » Newbie IDl 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: Newbie IDL question [message #52109 is a reply to message #28459] Mon, 08 January 2007 20:04 Go to previous messageGo to previous message
Braedley is currently offline  Braedley
Messages: 57
Registered: September 2006
Member
JD Smith wrote:
> On Mon, 08 Jan 2007 15:40:55 -0800, tony.ohagan wrote:
>
>> I new to IDL but have lots of experience in other programming languages.
>>
>> It appears that all nested control statements IF/CASE/WHILE etc force me
>> to
>> suffix every line with & $ to avoid syntax errors. Is there any way of
>> ridding myself of this pain?
>>
>> Example:
>>
>> name = 'Larry'
>> CASE name OF & $
>> 'Larry': PRINT, 'Stooge 1' & $
>> 'Moe': PRINT, 'Stooge 2' & $
>> 'Curly': PRINT, 'Stooge 3' & $
>> ELSE: PRINT, 'Not a Stooge' & $
>> ENDCASE
>
> Do you mean from the command line? Put them in a file foo.pro sans & $
> and:
>
> IDL> .run foo
>
> JD

If this already in a program, you don't need the & and $. If this is
at the command line, I must ask, why are you using a case block at the
command line? Seems, well, strange, but that's just me.

If you're using if, else, for, or while, and sometimes case and switch,
then you should be using begin and end[if|else|for|while]. Here's a
short example for each:

for stooge_num=0, 3 do begin
case stooge_num of
1:begin
name='Larry'
PRINT, 'Stooge 1'
end
2:begin
name='Curly'
PRINT, 'Stooge 2'
end
3:begin
name='Moe'
PRINT, 'Stooge 3'
end
else:begin
name=''
PRINT, 'Not A Stooge'
endelse
endcase
endfor
stooge_num=temporary(stooge_num)*(-2)
while stooge_num ne 0 do begin
if stooge_num ne abs(stooge_num) then begin
stooge_num=abs(temporary(stooge_num))
print, 'Ahh, negative number!'
endif else begin
stooge_num--
print, "We're on our way!"
endelse
endwhile
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Newbie IDL question
Next Topic: Writing on an image

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

Current Time: Sat Oct 11 01:57:10 PDT 2025

Total time taken to generate the page: 0.91876 seconds