Re: baffling syntax error [message #70568] |
Fri, 23 April 2010 12:56 |
R.G.Stockwell
Messages: 163 Registered: October 2004
|
Senior Member |
|
|
>
> "Gray" <graylikethecolor@gmail.com> wrote in message
> news:e6a63f50-7cd4-4ad8-a6c9-9c0832835ff8@d34g2000vbl.google groups.com...
>
> Well, here's what happened - the function that was being called was
> included in a file along with a bunch of other routines. I needed to
> write another wrapper to use some of those functions to work in a
> limited capacity only, so I was simply compiling the original wrapper
> file before I compiled my new wrapper file. BUT, at one point I
> forgot to do that, so I got the above error. Since I already write
> code in strict_arr anyway (it's much less confusing to read), I should
> just turn on idl2 out of habit, so these things don't happen.
That is what i was going for. And, setting idl2 does not prevent
you from getting an error in that scenario, though I assume you
get a more useful error message. :)
cheers,
bob
PS some idl users never compile a routine.
|
|
|
Re: baffling syntax error [message #70569 is a reply to message #70568] |
Fri, 23 April 2010 12:11  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Gray writes:
> Well, here's what happened - the function that was being called was
> included in a file along with a bunch of other routines. I needed to
> write another wrapper to use some of those functions to work in a
> limited capacity only, so I was simply compiling the original wrapper
> file before I compiled my new wrapper file. BUT, at one point I
> forgot to do that, so I got the above error. Since I already write
> code in strict_arr anyway (it's much less confusing to read), I should
> just turn on idl2 out of habit, so these things don't happen.
Well, order restored. File naming snafu. :-)
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.")
|
|
|
Re: baffling syntax error [message #70570 is a reply to message #70569] |
Fri, 23 April 2010 11:44  |
Gray
Messages: 253 Registered: February 2010
|
Senior Member |
|
|
On Apr 23, 1:36 pm, David Fanning <n...@dfanning.com> wrote:
> R.G. Stockwell writes:
>> agree. i'm just guessing as to the cause, and path problems are
>> very common. Could either be a newly created function that is not in
>> the cached path, or perhaps misnamed, or not in the path at all.
>
>> My point being, if it is a problem like that, then it will still be a
>> problem
>> in the future, and the compile option won't fix it.
>
> I've taken it as the Gospel truth that if files
> are named correctly this problem NEVER occurs:
>
> http://www.dfanning.com/tips/namefiles.html
>
> But I ran into a situation about a month ago, and I
> don't remember all the details now, but, basically,
> the ONLY way to solve the problem was to add a
> compile option. It made me wonder if IDL had changed
> something about the order in which it sorts things out,
> because I had never run into this problem before.
>
> I'll have to get a beer or two, probably, before I
> can remember all the details. :-(
>
> 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.")
Well, here's what happened - the function that was being called was
included in a file along with a bunch of other routines. I needed to
write another wrapper to use some of those functions to work in a
limited capacity only, so I was simply compiling the original wrapper
file before I compiled my new wrapper file. BUT, at one point I
forgot to do that, so I got the above error. Since I already write
code in strict_arr anyway (it's much less confusing to read), I should
just turn on idl2 out of habit, so these things don't happen.
|
|
|
Re: baffling syntax error [message #70571 is a reply to message #70570] |
Fri, 23 April 2010 10:36  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
R.G. Stockwell writes:
> agree. i'm just guessing as to the cause, and path problems are
> very common. Could either be a newly created function that is not in
> the cached path, or perhaps misnamed, or not in the path at all.
>
> My point being, if it is a problem like that, then it will still be a
> problem
> in the future, and the compile option won't fix it.
I've taken it as the Gospel truth that if files
are named correctly this problem NEVER occurs:
http://www.dfanning.com/tips/namefiles.html
But I ran into a situation about a month ago, and I
don't remember all the details now, but, basically,
the ONLY way to solve the problem was to add a
compile option. It made me wonder if IDL had changed
something about the order in which it sorts things out,
because I had never run into this problem before.
I'll have to get a beer or two, probably, before I
can remember all the details. :-(
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.")
|
|
|
Re: baffling syntax error [message #70572 is a reply to message #70571] |
Fri, 23 April 2010 09:49  |
R.G.Stockwell
Messages: 163 Registered: October 2004
|
Senior Member |
|
|
>
>
> "pp" <pp.penteado@gmail.com> wrote in message
> news:691274b1-c3fe-4a80-b984-822c70bdc9dc@g30g2000prf.google groups.com...
> On Apr 22, 7:49 pm, "R.G. Stockwell" <noem...@please.com> wrote:
>> "Gray" <grayliketheco...@gmail.com> wrote in message
>>
>> news:3fd12140-7afc-4375-b8d6-3bf139f1d2ab@e21g2000vbb.google groups.com...
>> On Apr 22, 5:16 pm, mgalloy <mgal...@gmail.com> wrote:> On 4/22/10 3:03
>> PM, Gray wrote:
>>
>> ....
>>
>>> Haha. I always forget about this, since I only index arrays with []
>>> thanks to my c++ background.
>>
>> one followup would be to figure out why this happened in the first
>> place.
>> You may not have paths/ etc set up correctly, causing IDL to think it
>> was an array.
>
> No path problems are needed. Without the compile_opt, if a name is
> used by a variable and there is no function with that name already
> compiled, IDL will assume it is a variable name, and will not try to
> find a function to compile. But if a compiled function uses a name,
> any references to the name will be interpreted as function calls,
> ignoring a variable of the same name, regardless of when the variable
> was defined.
agree. i'm just guessing as to the cause, and path problems are
very common. Could either be a newly created function that is not in
the cached path, or perhaps misnamed, or not in the path at all.
My point being, if it is a problem like that, then it will still be a
problem
in the future, and the compile option won't fix it.
cheers,
bob
|
|
|
Re: baffling syntax error [message #70579 is a reply to message #70572] |
Thu, 22 April 2010 16:16  |
penteado
Messages: 866 Registered: February 2018
|
Senior Member Administrator |
|
|
On Apr 22, 7:49 pm, "R.G. Stockwell" <noem...@please.com> wrote:
> "Gray" <grayliketheco...@gmail.com> wrote in message
>
> news:3fd12140-7afc-4375-b8d6-3bf139f1d2ab@e21g2000vbb.google groups.com...
> On Apr 22, 5:16 pm, mgalloy <mgal...@gmail.com> wrote:> On 4/22/10 3:03 PM, Gray wrote:
>
> ....
>
>> Haha. I always forget about this, since I only index arrays with []
>> thanks to my c++ background.
>
> one followup would be to figure out why this happened in the first place.
> You may not have paths/ etc set up correctly, causing IDL to think it
> was an array.
No path problems are needed. Without the compile_opt, if a name is
used by a variable and there is no function with that name already
compiled, IDL will assume it is a variable name, and will not try to
find a function to compile. But if a compiled function uses a name,
any references to the name will be interpreted as function calls,
ignoring a variable of the same name, regardless of when the variable
was defined.
|
|
|
Re: baffling syntax error [message #70580 is a reply to message #70579] |
Thu, 22 April 2010 15:49  |
R.G.Stockwell
Messages: 163 Registered: October 2004
|
Senior Member |
|
|
"Gray" <graylikethecolor@gmail.com> wrote in message
news:3fd12140-7afc-4375-b8d6-3bf139f1d2ab@e21g2000vbb.google groups.com...
On Apr 22, 5:16 pm, mgalloy <mgal...@gmail.com> wrote:
> On 4/22/10 3:03 PM, Gray wrote:
....
> Haha. I always forget about this, since I only index arrays with []
> thanks to my c++ background.
one followup would be to figure out why this happened in the first place.
You may not have paths/ etc set up correctly, causing IDL to think it
was an array.
|
|
|
Re: baffling syntax error [message #70582 is a reply to message #70580] |
Thu, 22 April 2010 14:29  |
Gray
Messages: 253 Registered: February 2010
|
Senior Member |
|
|
On Apr 22, 5:16 pm, mgalloy <mgal...@gmail.com> wrote:
> On 4/22/10 3:03 PM, Gray wrote:
>
>
>
>
>
>> Hi all,
>
>> I have a function declaration with both positional and keyword
>> parameters like this:
>
>> FUNCTION WR_subtract, imga, imgb, WARP_DEG=wdeg, SKY_STYLE=skyst, $
>> SCALE_STYLE=scast
>
>> ...and in another procedure I call the function like this:
>
>> interp_res =
>> wr_subtract(intrp,civ,warp_deg=3.,sky_style=1,scale_style=1)
>
>> However, that function call gives me a syntax error when I try to
>> compile:
>
>> interp_res =
>> wr_subtract(intrp,civ,warp_deg=3.,sky_style=1,scale_style=1)
>> ^
>> % Syntax error.
>
>> Why the error??
>
>> Thanks!
>> --Gray
>
> I would guess that IDL thinks that "wr_subtract" is an array and you
> invalidly indexing it. Fix this with a "compile_opt strictarr" statement
> at the beginning of the routine that *calls* wr_subtract (and, of
> course, by using []'s, not ()'s, to index arrays inside that routine).
>
> Mike
> --www.michaelgalloy.com
> Research Mathematician
> Tech-X Corporation
Haha. I always forget about this, since I only index arrays with []
thanks to my c++ background.
|
|
|
Re: baffling syntax error [message #70583 is a reply to message #70582] |
Thu, 22 April 2010 14:16  |
Michael Galloy
Messages: 1114 Registered: April 2006
|
Senior Member |
|
|
On 4/22/10 3:03 PM, Gray wrote:
> Hi all,
>
> I have a function declaration with both positional and keyword
> parameters like this:
>
> FUNCTION WR_subtract, imga, imgb, WARP_DEG=wdeg, SKY_STYLE=skyst, $
> SCALE_STYLE=scast
>
> ...and in another procedure I call the function like this:
>
> interp_res =
> wr_subtract(intrp,civ,warp_deg=3.,sky_style=1,scale_style=1)
>
> However, that function call gives me a syntax error when I try to
> compile:
>
> interp_res =
> wr_subtract(intrp,civ,warp_deg=3.,sky_style=1,scale_style=1)
> ^
> % Syntax error.
>
> Why the error??
>
> Thanks!
> --Gray
I would guess that IDL thinks that "wr_subtract" is an array and you
invalidly indexing it. Fix this with a "compile_opt strictarr" statement
at the beginning of the routine that *calls* wr_subtract (and, of
course, by using []'s, not ()'s, to index arrays inside that routine).
Mike
--
www.michaelgalloy.com
Research Mathematician
Tech-X Corporation
|
|
|
Re: baffling syntax error [message #70584 is a reply to message #70583] |
Thu, 22 April 2010 14:14  |
penteado
Messages: 866 Registered: February 2018
|
Senior Member Administrator |
|
|
On Apr 22, 6:04 pm, Gray <grayliketheco...@gmail.com> wrote:
> On Apr 22, 5:03 pm, Gray <grayliketheco...@gmail.com> wrote:
>
>
>
>
>
>> Hi all,
>
>> I have a function declaration with both positional and keyword
>> parameters like this:
>
>> FUNCTION WR_subtract, imga, imgb, WARP_DEG=wdeg, SKY_STYLE=skyst, $
>> SCALE_STYLE=scast
>
>> ...and in another procedure I call the function like this:
>
>> interp_res =
>> wr_subtract(intrp,civ,warp_deg=3.,sky_style=1,scale_style=1)
>
>> However, that function call gives me a syntax error when I try to
>> compile:
>
>> interp_res =
>> wr_subtract(intrp,civ,warp_deg=3.,sky_style=1,scale_style=1)
>> ^
>> % Syntax error.
>
>> Why the error??
>
>> Thanks!
>> --Gray
>
> Hm... because of text wrapping, that didn't quite work. The error is
> apparently at "warp_deg=3.".
Sounds like IDL is interpreting wr_subtract(...) as an array, not a
function. Do you use compile_opt idl2?
|
|
|
Re: baffling syntax error [message #70585 is a reply to message #70584] |
Thu, 22 April 2010 14:04  |
Gray
Messages: 253 Registered: February 2010
|
Senior Member |
|
|
On Apr 22, 5:03 pm, Gray <grayliketheco...@gmail.com> wrote:
> Hi all,
>
> I have a function declaration with both positional and keyword
> parameters like this:
>
> FUNCTION WR_subtract, imga, imgb, WARP_DEG=wdeg, SKY_STYLE=skyst, $
> SCALE_STYLE=scast
>
> ...and in another procedure I call the function like this:
>
> interp_res =
> wr_subtract(intrp,civ,warp_deg=3.,sky_style=1,scale_style=1)
>
> However, that function call gives me a syntax error when I try to
> compile:
>
> interp_res =
> wr_subtract(intrp,civ,warp_deg=3.,sky_style=1,scale_style=1)
> ^
> % Syntax error.
>
> Why the error??
>
> Thanks!
> --Gray
Hm... because of text wrapping, that didn't quite work. The error is
apparently at "warp_deg=3.".
|
|
|