Re: Weirdest Error Ever [message #50743] |
Thu, 19 October 2006 00:56  |
Karsten Rodenacker
Messages: 98 Registered: July 1997
|
Member |
|
|
Am Wed, 18 Oct 2006 19:37:13 +0200 schrieb David Fanning
<news@dfanning.com>:
> File that works perfectly:
> bar = BYTSCL(bar, TOP=(ncolors-1 < (255-bottom))) + bottom
> File that fails:
> bar = BYTSCL(bar, TOP=(ncolors-1) < (255-bottom)) + bottom
This reminds me on a syntax error which is again and again bothering me:
IDL> help,1 < -5
help,1 < -5
^
% Syntax error.
IDL> help,1 < (-5)
<Expression> INT = -5
Possibly ...
Regards
Karsten
--
Erstellt mit Operas revolutionᅵrem E-Mail-Modul: http://www.opera.com/m2/
|
|
|
|
Re: Weirdest Error Ever [message #50750 is a reply to message #50749] |
Wed, 18 October 2006 11:51   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
David Fanning writes:
> Yeah, yeah. IDL is confused. It thinks a function call
> is a variable reference. I get that that. I even understand
> how this works internally (more or less).
>
> What I don't get is how THIS line causes the confusion:
>
> bar = BYTSCL(bar, TOP=(ncolors-1) < (255-bottom)) + bottom
>
> And this line doesn't:
>
> bar = BYTSCL(bar, TOP=(ncolors-1 < (255-bottom))) + bottom
>
> Any insights into that?
I guess it's fair to wonder why I care about this. One
reason I care is that I think the line that causes
confusion is the correct way to write the line, since
it is less ambiguous than the second way. :-)
Cheers,
David
P.S. Anyone can fix problems. Experts, though, are suppose
to understand why a whack on the side of the box fixes
the damn thing.
--
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: Weirdest Error Ever [message #50753 is a reply to message #50751] |
Wed, 18 October 2006 11:32   |
Foldy Lajos
Messages: 268 Registered: October 2001
|
Senior Member |
|
|
On Wed, 18 Oct 2006, David Fanning wrote:
> Even MORE oddly, if I start a fresh session and compile REVERSE
> before I do anything else, the program that fails works perfectly!!
When compiling COLORBAR, IDL sees that it has a function named REVERSE,
so emits a function call op.
> If I start a fresh session and compile the program that fails, then
> compile REVERSE, then run the program, it *still* fails.
When compiling COLORBAR, IDL sees that it has no function named REVERSE,
so emits an array subscripting op.
Function lookup comes first, then array subscripting. So, this part can be
explained :-)
regards,
lajos
|
|
|
Re: Weirdest Error Ever [message #50755 is a reply to message #50753] |
Wed, 18 October 2006 11:10   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
David Fanning writes:
> Lajos writes:
>
>> don't you have a 1D array named Reverse somewhere? Have you tried
>> compile_opt strictarr?
>
> Yes, I can fix it with compile_opt StrictArr, too.
> And I have now narrowed the problem down to IDL
> thinking the REVERSE(bar) call is a subscripted
> variable call and not a function call. I know
> how to *fix* this--I have a version that works,
> after all.
>
> What I am interested in knowing is how this line:
>
> bar = BYTSCL(bar, TOP=(ncolors-1) < (255-bottom)) + bottom
>
> confuses IDL into thinking my REVERSE call two lines
> later is a variable subscript and not a function call.
> What is THAT all about!?
I guess I should mention, too, although you probably
already realize this, that I have a REVERSE keyword
defined for the COLORBAR routine. When I enter the
program the *variable* reverse is set to 1. I didn't
mention this before because someone is invariably going
to point out that I also have an INVERTCOLORS keyword
defined that does the very same thing as my REVERSE
keyword and why the hell do you have TWO of them defined!?
I just didn't want to get into all that. :-(
But the fundamental question still remains. Why does
that line above confuse IDL about what REVERSE is?
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: Weirdest Error Ever [message #50758 is a reply to message #50756] |
Wed, 18 October 2006 10:44   |
Foldy Lajos
Messages: 268 Registered: October 2001
|
Senior Member |
|
|
On Wed, 18 Oct 2006, David Fanning wrote:
> Folks,
>
> I've been working this morning on an error that is so
> weird I'm beginning to think it is possible I have
> completely lost my mind.
>
> The error occurs in my COLORBAR routine. I have two
> files. The files are identical, except for the following
> line.
>
> File that works perfectly:
>
> bar = BYTSCL(bar, TOP=(ncolors-1 < (255-bottom))) + bottom
>
> File that fails:
>
> bar = BYTSCL(bar, TOP=(ncolors-1) < (255-bottom)) + bottom
>
> In both files, the following three lines follow the line above:
>
> IF Keyword_Set(reverse) THEN BEGIN
> bar = Reverse(bar,1)
> ENDIF
>
> The variable bar is defined originally like this:
>
> bar = BINDGEN(ncolors) # REPLICATE(1B, 20)
>
> where ncolors is 256, so it is a 256 by 20 byte array. The variable
> bottom is 0.
>
> The error occurs on the line containing REVERSE. Here is the error:
>
> IDL> Colorbar, /Reverse
> Subscript range values of the form low:high must be >= 0, < size,
> with low <= high: REVERSE.
> Error occurred at: COLORBAR 286 C:\RSI\IDL Course\colorbar.pro
> $MAIN$
> Execution halted at: $MAIN$
>
> Oddly, REVERSE, which is an IDL library routine is *not* compiled
> when the error occurs, and I am certain the error is not coming from
> REVERSE, because I can't step into REVERSE as I try to debug the
> program. I think the error is a system error from IDL
>
> Even MORE oddly, if I start a fresh session and compile REVERSE
> before I do anything else, the program that fails works perfectly!!
> If I start a fresh session and compile the program that fails, then
> compile REVERSE, then run the program, it *still* fails.
>
> Here is the result of HELP, /SOURCE in the latter case, which
> is *identical* to the same command in the former case:
>
> IDL> help, /source
> Compiled Procedures:
> $MAIN$
> COLORBAR C:\RSI\IDL Course\colorbar.pro
>
> Compiled Functions:
> REVERSE C:\RSI\IDL62\lib\reverse.pro
>
> If I start a fresh session and just try to execute the code that
> seems to be giving me problems here, I have NO problem!
>
> IDL> ncolors=256
> IDL> bottom=0
> IDL> bar = BINDGEN(ncolors) # REPLICATE(1B, 20)
> IDL> bar = BYTSCL(bar, TOP=(ncolors-1) < (255-bottom)) + bottom
> IDL> bar = reverse(bar, 1)
> Compiled module: REVERSE.
>
> Does anyone have the foggiest idea of what could be going on here!?
>
> 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.")
>
Hi David,
don't you have a 1D array named Reverse somewhere? Have you tried
compile_opt strictarr?
regards,
lajos
|
|
|
|
Re: Weirdest Error Ever [message #50885 is a reply to message #50743] |
Thu, 19 October 2006 07:59  |
Michael Galloy
Messages: 1114 Registered: April 2006
|
Senior Member |
|
|
Karsten Rodenacker wrote:
> This reminds me on a syntax error which is again and again bothering me:
>
> IDL> help,1 < -5
>
> help,1 < -5
> ^
> % Syntax error.
> IDL> help,1 < (-5)
> <Expression> INT = -5
> Possibly ...
This error is because <, >, +, and - have the same order of precedence.
So they are parsed left to right; "1 < -" is a syntax error. It does
mean that David is right in wanting to put ()'s around operands in a <
or > expressions (though in his particular case it was OK without them).
Mike
--
www.michaelgalloy.com
|
|
|