Re: what's wrong with this? --- ' vs " problem [message #39224] |
Tue, 04 May 2004 10:49  |
Norbert Hahn
Messages: 46 Registered: May 2003
|
Member |
|
|
mmiller3@iupui.edu (Michael A. Miller) wrote:
> Ok, this I don"t get. Is it a 'feature' or a "bug"? I vote for
> bug in how IDL parses octal numbers.
It's a poor feature. A string starting with " followed by a digit
starts an octal input, not necessarily a number. Thus your input
> IDL> file=" 040301_0932_2004-00005_mouse1_12x10s-4x30s-3x120s-4x300s-pro j.jpg "
make file a variable of type Int and a value of octal 040301, decimal
16577.
If you enter file="0403010932 then the variable type is long and the
value in decimal is 543213431.
The underline character is not a valid octal digit, hence "Syntax error".
HTH
Norbert
|
|
|
Re: what's wrong with this? --- ' vs " problem [message #39227 is a reply to message #39224] |
Tue, 04 May 2004 07:54   |
mmiller3
Messages: 81 Registered: January 2002
|
Member |
|
|
>>>> > "David" == David Fanning <david@dfanning.com> writes:
> Michael A. Miller writes:
>> Ok, this I don"t get. Is it a 'feature' or a "bug"? I
>> vote for bug in how IDL parses octal numbers.
> Well, if it's a bug, it's been a bug for the last 20
> years. :-)
That's what I thought. And I can't for the life of me figure out
why it took so many years for me to notice it! Blech.
I did find some documentation in chapter 3 of "Building IDL
Applications", but there is more. In talking to my neighbors
about this, it was pointed out that the final ' or " is not
required to correctly delimit a string, so that all of the
following are the same string constant:
"Don't drink the water"
"Don't drink the water
'Don''t drink the water'
'Don''t drink the water
I could happily go along being unaware of this, except I wrote a
script that calls some IDL like this
echo indypet_projections, \"$img\" > do_this.pro
echo exit >> do_this.pro
idl do_this.pro > do_this.log 2>&1
sometimes this fails, depending on what the string in img is. So
I fixed it by replacing the "s with 's. But I'm not yet
convinced that I won't have cases where I need to use " to
delimit some string and ' to delimit others. So I wonder if I
need to write an IDL-like parser that can decide in advance how
to delimit strings so that IDL likes them. Of course if IDL had
a built-in mechanism for handling command line arguments, I could
let the RSI gang do that for me...
None of this fits my bias about how IDL is supposed to work,
which is exactly like I want it to that is ... I'm grudgingly
willing to count as a feature :-)
Mike
|
|
|
|
Re: what's wrong with this? --- ' vs " problem [message #39300 is a reply to message #39224] |
Wed, 05 May 2004 15:44  |
JD Smith
Messages: 850 Registered: December 1999
|
Senior Member |
|
|
On Tue, 04 May 2004 19:49:45 +0200, Norbert Hahn wrote:
> mmiller3@iupui.edu (Michael A. Miller) wrote:
>
>> Ok, this I don"t get. Is it a 'feature' or a "bug"? I vote for
>> bug in how IDL parses octal numbers.
>
> It's a poor feature. A string starting with " followed by a digit
> starts an octal input, not necessarily a number. Thus your input
>
>> IDL> file=" 040301_0932_2004-00005_mouse1_12x10s-4x30s-3x120s-4x300s-pro j.jpg "
>
> make file a variable of type Int and a value of octal 040301, decimal
> 16577.
>
> If you enter file="0403010932 then the variable type is long and the
> value in decimal is 543213431.
>
> The underline character is not a valid octal digit, hence "Syntax error".
I vote for a COMPILE_OPT option turning off this "feature". Whoever
decided to use unpaired string delimeters for octal constants probably
hadn't yet written the interpreter to actually recognize those
constants. A much better syntax, should you have a need for octals,
is:
angstrom=string('305'OB)
which has the advantage that it matches the hexadecimal notation:
angstrom=string('C5'XB)
I guess we should be thankful they didn't offer 'HHH as a hexadecimal
shorthand.
JD
P.S. Use of "NNN octal notation in IDLWAVE tends to wreak havoc with
the fontification.
|
|
|