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

Home » Public Forums » archive » Re: Beginner fails miserabley at first hurdle 0.05 0.05
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: Beginner fails miserabley at first hurdle 0.05 0.05 [message #10898] Fri, 06 February 1998 00:00 Go to previous message
David Foster is currently offline  David Foster
Messages: 341
Registered: January 1996
Senior Member
clovis21@hotmail.com wrote:
>
> Hello all, I'm just starting, but I've come unstuck already. I'm
> trying to write a for .. do begin line, but I can't seem to get it to
> work:
>
> for i=0, 31 do $
> for k=0, 31 do $
> for j=0, 255 DO BEGIN
> real_b(i, k, j)=b(i, k, 2*j)
> imag_b(i, k, j)=b(i, k, (2*j)+1)
> print, i, k, j
> endfor
>
> In desperation I've tried the following:
>
> for i=1, 100 do begin
> print, i
> endfor
>
> and all that happens is that I get 101 printed, then a syntax error on
> the 'n' of endfor. What have I done wrong?
>
> Martin

Martin -

Hang in there man! Since IDL is interpreted line-by-line as you
enter commands, you can't enter loop constructs like you tried,
because those kinds of statements need to be *compiled*. To enter
these commands at the IDL prompt:

IDL> .run
- for i=1,100 do begin
- print, i
- endfor
- end

and you will get what you expect. Or you can do it on one line:

IDL> for i=1,100 do print, i

If you enter your commands like these examples, or put them into
a properly written .pro file and compile them, your statements
will work just fine:

; test.pro
PRO test, real_b, imag_b, b

for i=0, 31 do $
for k=0, 31 do $
for j=0, 255 DO BEGIN
real_b(i, k, j)=b(i, k, 2*j)
imag_b(i, k, j)=b(i, k, (2*j)+1)
print, i, k, j
endfor
return
end


Hope this helps.

Dave
--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
David S. Foster Univ. of California, San Diego
Programmer/Analyst Brain Image Analysis Laboratory
foster@bial1.ucsd.edu Department of Psychiatry
(619) 622-5892 8950 Via La Jolla Drive, Suite 2240
La Jolla, CA 92037
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
[Message index]
 
Read Message
Read Message
Previous Topic: Re: vector plots on maps
Next Topic: Re: Q: debuggging widget applications in IDL 5

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

Current Time: Sat Oct 11 15:06:24 PDT 2025

Total time taken to generate the page: 1.04229 seconds