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

Home » Public Forums » archive » Re: how to do a loop in idl using multi-commmand?
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: how to do a loop in idl using multi-commmand? [message #43530 is a reply to message #43529] Fri, 15 April 2005 12:49 Go to previous messageGo to previous message
Benjamin Hornberger is currently offline  Benjamin Hornberger
Messages: 258
Registered: March 2004
Senior Member
If you do @filename, it runs as a batch file, meaning every statement,
line by line, is executed as if they were typed on the command line one
by one. You get the same error as on the command line.

What was meant in the previous post is a main-level program which has to
have an END statement and is run by ".run filename".

Go to the IDL help index and search for "batch file", then choose the
subentry "defined". You'll find a description of batch files, main-level
programs and named programs. David Fanning's book also describes it in
detail.

If you want a FOR loop on the command line or in a batch file, you'll
have to write it in one line, combining statements by "&":

FOR I=0, 10000 DO BEGIN & x=2*nH2[i] & y=x*nH2[i] & ratio[i]=x/y & ENDFOR

Note that the news client might have introduced a line break. This must
be all in one line! I guess you realize it's better (more elegant, more
understandable) to put it into a main-level or named program.

Good luck,
Benjamin

lixiaoyao wrote:
> I use @filename.pro to run it,it is still wrong. any other suggestion?
> for i=0,10000 do
> ^
> % Syntax error.
> At: /n/a/liletian/test.pro, Line 3
> % Variable is undefined: I.
> % Execution halted at: $MAIN$
> % Variable is undefined: I.
> % Execution halted at: $MAIN$
> % Variable is undefined: Y.
> % Execution halted at: $MAIN$
>
> endfor
> ^
> % Syntax error.
> At: /n/a/liletian/test.pro, Line 9
>
> end
> ^
> % Syntax error.
> At: /n/a/liletian/test.pro, Line 13
>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Nice ways to compile
Next Topic: .compile vs .run

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

Current Time: Sat Nov 29 15:07:59 PST 2025

Total time taken to generate the page: 1.52091 seconds