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

Home » Public Forums » archive » Program to convert (i) to [i] ?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Program to convert (i) to [i] ? [message #73560] Fri, 19 November 2010 13:27 Go to next message
M. Katz is currently offline  M. Katz
Messages: 69
Registered: May 2005
Member
Some time ago, in a posting before the release of IDL 8, I remember
people discussing the forced use of square brackets [] for array
indices. While I have been thoroughly converted to square bracket
arrays since the early 2000s, I still rely on thousands of lines of
older code that has a lot of parentheses ().

Someone mentioned a program that could intelligently convert code en
masse, but I cannot now find that reference. Can anyone point me in
the correct direction, or share their experience with using it? How
does it know which of your labels are your own .pro functions and
which are variable names when there is an ambiguity?

Is there a COMPILE_OPT setting to allow the use of older () array
indices? I'm running IDL 8.0.1 now.

Thanks,
M.
Re: Program to convert (i) to [i] ? [message #73698 is a reply to message #73560] Sat, 20 November 2010 22:31 Go to previous message
M. Katz is currently offline  M. Katz
Messages: 69
Registered: May 2005
Member
Wonderful. Thank you. I'll try it!
Re: Program to convert (i) to [i] ? [message #73700 is a reply to message #73560] Sat, 20 November 2010 11:27 Go to previous message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
On Nov 19, 4:27 pm, "M. Katz" <MKatz...@yahoo.com> wrote:

>
> Someone mentioned a program that could intelligently convert code en
> masse, but I cannot now find that reference. Can anyone point me in
> the correct direction, or share their experience with using it?

The program idlv4_to_v5 is in http://idlastro.gsfc.nasa.gov/ftp/contrib/landsman/v5/
. See the README file there.

> How
> does it know which of your labels are your own .pro functions and
> which are variable names when there is an ambiguity?

It uses RESOLVE_ROUTINE and ROUTINE_INFO to make a list of available
functions for the current !PATH. It then assumes that any
function_or_variable() is a function if it is in this list, and
otherwise is a variable. So it resolves the ambiguity the same way
the IDL session would (though not necessarily the way the user
intended).

The program does sometimes have problems with parentheses written
within quotes, or with parentheses split among multiple line, but it
usually gives a warning when it gets confused. So a few procedures
required further manual editing.

Disclaimer: I was quite happy with the effectiveness of this procedure
when I used it, but I haven't used it in many years. -Wayne
Re: Program to convert (i) to [i] ? [message #73702 is a reply to message #73560] Sat, 20 November 2010 09:50 Go to previous message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
On Nov 20, 1:52 pm, jeanh
<jghasb...@DELETETHIS.environmentalmodelers.ANDTHIS.com> wrote:

> I guess one could write a small program that use strictarr, and create a
> new .pro file. When an error occurs, the program change the () to [] and
> moves on, saving the updated code in the new file...

But keeping in mind that would still be a guess, as there are cases
where the wrong interpretation of the () would not throw an error.
Re: Program to convert (i) to [i] ? [message #73704 is a reply to message #73560] Sat, 20 November 2010 07:52 Go to previous message
jeanh is currently offline  jeanh
Messages: 79
Registered: November 2009
Member
On 19/11/2010 6:27 PM, Paulo Penteado wrote:
> On Nov 19, 7:27 pm, "M. Katz"<MKatz...@yahoo.com> wrote:
>> Is there a COMPILE_OPT setting to allow the use of older () array
>> indices? I'm running IDL 8.0.1 now.
>
> They are (still) allowed by default. There is the option strictarr
> that does the opposite, disallowing them.

I guess one could write a small program that use strictarr, and create a
new .pro file. When an error occurs, the program change the () to [] and
moves on, saving the updated code in the new file...

Jean
Re: Program to convert (i) to [i] ? [message #73707 is a reply to message #73560] Fri, 19 November 2010 15:27 Go to previous message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
On Nov 19, 7:27 pm, "M. Katz" <MKatz...@yahoo.com> wrote:
> Is there a COMPILE_OPT setting to allow the use of older () array
> indices? I'm running IDL 8.0.1 now.

They are (still) allowed by default. There is the option strictarr
that does the opposite, disallowing them.
Re: Program to convert (i) to [i] ? [message #73708 is a reply to message #73560] Fri, 19 November 2010 15:19 Go to previous message
M. Katz is currently offline  M. Katz
Messages: 69
Registered: May 2005
Member
These don't seem to work either ;)

Compile_Opt dinosaur
Compile_Opt run_faster
Compile_Opt forgive_mistakes


P.S. I myself have one of those 17 year old startup files (modified
many times along the way).
Re: Program to convert (i) to [i] ? [message #73709 is a reply to message #73560] Fri, 19 November 2010 13:38 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
M. Katz writes:

> Is there a COMPILE_OPT setting to allow the use of older () array
> indices? I'm running IDL 8.0.1 now.

Have you tried this:

Compile_Opt oldschool

The wheels turn slowly. How many of us are
still wondering what a widget is?

Cheers,

David

P.S. Let's just say if we could convince everyone
to get rid of the IDL start-up files bequeathed to
them by their graduate school mentor we might make
some progress. :-)

--
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.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Correct Image Resizing -- New Coyote Program
Next Topic: IDL 8.0.1 ARG_PRESENT question

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

Current Time: Wed Oct 08 15:12:37 PDT 2025

Total time taken to generate the page: 0.03442 seconds