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

Home » Public Forums » archive » Newbie's 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's question [message #53406 is a reply to message #45924] Sat, 14 April 2007 10:04 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
geonline714@gmail.com writes:

> I tried to run a script like this (stored in test.pro):
>
> array = ['one', 'two', 'three']
> print, array
> n = N_ELEMENTS(array)
> print, n
> FOR i=0,n-1 DO BEGIN
> PRINT, array[i]
> ENDFOR
>
>
> However, I got error message as follows:
>
> IDL> @test
> one two three
> 3
> Attempt to subscript ARRAY with I is out of range.
> Execution halted at: $MAIN$
>
> ENDFOR
> ^
> Syntax error.
> At: E:\temp\test.pro, Line 7
>
>
> This is an example from IDL. Do you have any idea about what is going
> on?

The @ sign attempts to read the instructions in the file
as if you were typing them at the IDL command line. That
is, one after the other. But, it is VERY difficult to
write multiple line commands, such as in your FOR loop,
at the IDL command line. You will need line continuation
and line concatenation symbols to do so. NO ONE WANTS TO
DO THAT!

So, what you want to do is compile this bunch of commands
you have FIRST, then execute that. BUT, in order to make
these command compilable, there has to be an END statement
at the end of the commands, so the compiler knows where
to stop. That is what is missing in your code (and is
probably what you have left out of the example).

What you want to do with this code is add an END statement.
Then compile the commands:

IDL> .compile test

Then run this main-level program:

IDL> .go

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: newbie's question
Next Topic: Re: FIX FOR FC5 SEG FAULTS

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

Current Time: Sat Oct 11 13:45:36 PDT 2025

Total time taken to generate the page: 0.63880 seconds