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?
Um, looks to me as if you are entering this at the command line, right?
Then you should try
for i=1, 100 do begin print, i & endfor
The & tells IDL that there is something following.
The other (usual) way would be to put the stuff into a file, e.g.
test.pro, which looks like this:
pro test
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
end
When you then enter 'test' at the command line, this file will be
compiled, and the procedure test will be executed.
Or you skip the first 'pro test' line, and start the program with '.run
test'.
Alex
--
Alex Schuster Wonko@weird.cologne.de PGP Key available
alex@pet.mpin-koeln.mpg.de
|