Writing programs to use static methods but still compile in IDL 7 [message #91803] |
Sun, 30 August 2015 09:05  |
wlandsman
Messages: 743 Registered: June 2000
|
Senior Member |
|
|
I am trying to update my code to use the static methods introduced in IDL 8.4 when the user has V8.4 or later. So I write a statement like the following
if !VERSION.RELEASE GE '8.4' then return,str.replace(in,out)
This works in IDL 8.0 and later but in IDL 7.1.1 and earlier it gives a compilation syntax error.
compile_opt idl2
if !VERSION.RELEASE GE '8.4' then return,str.replace(in,out)
% Syntax Error. Attempt to subscript array with parenthesis. Please use '[]'.
Is there a way to have a program use the static methods when the user has IDL 8.4 or later without causing a compilation syntax error in IDL 7?
An example program is
http://idlastro.gsfc.nasa.gov/ftp/pro/misc/repstr.pro
Thanks, --Wayne
|
|
|
Re: Writing programs to use static methods but still compile in IDL 7 [message #91804 is a reply to message #91803] |
Sun, 30 August 2015 10:29   |
Heinz Stege
Messages: 189 Registered: January 2003
|
Senior Member |
|
|
On Sun, 30 Aug 2015 09:05:40 -0700 (PDT), wlandsman wrote:
> I am trying to update my code to use the static methods introduced in IDL 8.4 when the user has V8.4 or later. So I write a statement like the following
>
> if !VERSION.RELEASE GE '8.4' then return,str.replace(in,out)
>
> This works in IDL 8.0 and later but in IDL 7.1.1 and earlier it gives a compilation syntax error.
>
>
> compile_opt idl2
> if !VERSION.RELEASE GE '8.4' then return,str.replace(in,out)
> % Syntax Error. Attempt to subscript array with parenthesis. Please use '[]'.
>
> Is there a way to have a program use the static methods when the user has IDL 8.4 or later without causing a compilation syntax error in IDL 7?
>
> An example program is
> http://idlastro.gsfc.nasa.gov/ftp/pro/misc/repstr.pro
>
> Thanks, --Wayne
Just an idea: Does
if !VERSION.RELEASE GE '8.4' then $
return,call_method('replace',a,in,out)
work? I don't have version 7 installed on my computer.
Cheers, Heinz
|
|
|
Re: Writing programs to use static methods but still compile in IDL 7 [message #91805 is a reply to message #91804] |
Sun, 30 August 2015 10:35   |
Heinz Stege
Messages: 189 Registered: January 2003
|
Senior Member |
|
|
On Sun, 30 Aug 2015 19:29:13 +0200, Heinz Stege wrote:
> Just an idea: Does
> if !VERSION.RELEASE GE '8.4' then $
> return,call_method('replace',a,in,out)
> work? I don't have version 7 installed on my computer.
No, I wanted to write:
if !VERSION.RELEASE GE '8.4' then $
return,call_method('replace',str,in,out)
Heinz
|
|
|
Re: Writing programs to use static methods but still compile in IDL 7 [message #91812 is a reply to message #91805] |
Mon, 31 August 2015 07:57  |
wlandsman
Messages: 743 Registered: June 2000
|
Senior Member |
|
|
Heinz,
Thanks! This syntax works in IDL 8.4 and later but still compiles in IDL 7.1. --Wayne
On Sunday, August 30, 2015 at 1:34:49 PM UTC-4, Heinz Stege wrote:
>
> No, I wanted to write:
> if !VERSION.RELEASE GE '8.4' then $
> return,call_method('replace',str,in,out)
>
> Heinz
|
|
|