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

Home » Public Forums » archive » Odd string/index problem
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
Odd string/index problem [message #21685] Wed, 13 September 2000 00:00 Go to next message
wmc is currently offline  wmc
Messages: 117
Registered: February 1995
Senior Member
Can someone explain this to me:

wmc> a='stoat'
wmc> print,a([0]),'>'
stoat
>
wmc> print,a(0),'>'
stoat>

This irritation surfaced when I tried to do
i=where(strings eq somestring)
print,strings(i)

which needs to be
i=i[0]
print,strings(i)

but why?

-W.

--
William M Connolley | wmc@bas.ac.uk | http://www.nerc-bas.ac.uk/icd/wmc/
Climate Modeller, British Antarctic Survey | Disclaimer: I speak for myself
Re: Odd string/index problem [message #21763 is a reply to message #21685] Thu, 14 September 2000 00:00 Go to previous message
wmc is currently offline  wmc
Messages: 117
Registered: February 1995
Senior Member
Martin Schultz <martin.schultz@dkrz.de> wrote:
>> [...] after printing an array, IDL always starts a new line

>> OK, its an array, but is it acceptable that IDL always starts a new line
>> after printing an array? Whats the justification for that?

> a = findgen(10)
> b = findgen(20)
> c = indgen(4)

> print,a,b,c

No, this is cheating, in this case print clearly has to do formatting,
since the items are numeric. In the case of strings, the need to exta
formatting is not clear.

-W.

--
William M Connolley | wmc@bas.ac.uk | http://www.nerc-bas.ac.uk/icd/wmc/
Climate Modeller, British Antarctic Survey | Disclaimer: I speak for myself
Re: Odd string/index problem [message #21767 is a reply to message #21685] Thu, 14 September 2000 00:00 Go to previous message
Paul van Delst is currently offline  Paul van Delst
Messages: 364
Registered: March 1997
Senior Member
wmc@bas.ac.uk wrote:
>
> marc <m_schellens@hotmail.com> wrote:
>> wmc@bas.ac.uk wrote:
>>> wmc> a='stoat'
>>> wmc> print,a([0]),'>'
>>> stoat
>>>>
>>> wmc> print,a(0),'>'
>>> stoat>
>
>> This is because your i is an array, while i[0] is a scalar.
>> therefore strings(i) is a string array, while strings(i[0]) is a scalar.
>
>> after printing an array, IDL always starts a new line
>
> OK, its an array, but is it acceptable that IDL always starts a new line
> after printing an array? Whats the justification for that?
>

IDL> a = [ 1,2,4,7,11 ]
IDL> b = [ 2.0,3.7,4.0 ]
IDL> c = [ 2,6,4,9,4,2,7 ]
IDL> print, a, b, c, FORMAT = '( 5i5,3f7.3,7i5 )'
1 2 4 7 11 2.000 3.700 4.000 2 6 4 9
4 2 7
IDL> print, a, b, c
1 2 4 7 11
2.00000 3.70000 4.00000
2 6 4 9 4 2 7

Well, I gotta tell you, I prefer the default option.

I print out full arrays more often than single elements (or single
element arrays). If the first example was the default it would be pretty
annoying don't you reckon?

paulv

--
Paul van Delst Ph: (301) 763-8000 x7274
CIMSS @ NOAA/NCEP Fax: (301) 763-8545
Rm.202, 5200 Auth Rd. Email: pvandelst@ncep.noaa.gov
Camp Springs MD 20746
Re: Odd string/index problem [message #21770 is a reply to message #21685] Thu, 14 September 2000 00:00 Go to previous message
Martin Schultz is currently offline  Martin Schultz
Messages: 515
Registered: August 1997
Senior Member
> after printing an array, IDL always starts a new line
>
> OK, its an array, but is it acceptable that IDL always starts a new line
> after printing an array? Whats the justification for that?
>

I really like this feature! Say you have
a = findgen(10)
b = findgen(20)
c = indgen(4)

print,a,b,c

It would be much harder to distinguish between the arrays if IDL would
not break the line.

Martin

--
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
[[ Dr. Martin Schultz Max-Planck-Institut fuer Meteorologie [[
[[ Bundesstr. 55, 20146 Hamburg [[
[[ phone: +49 40 41173-308 [[
[[ fax: +49 40 41173-298 [[
[[ martin.schultz@dkrz.de [[
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
Re: Odd string/index problem [message #21771 is a reply to message #21685] Thu, 14 September 2000 00:00 Go to previous message
wmc is currently offline  wmc
Messages: 117
Registered: February 1995
Senior Member
marc <m_schellens@hotmail.com> wrote:
> wmc@bas.ac.uk wrote:
>> wmc> a='stoat'
>> wmc> print,a([0]),'>'
>> stoat
>>>
>> wmc> print,a(0),'>'
>> stoat>

> This is because your i is an array, while i[0] is a scalar.
> therefore strings(i) is a string array, while strings(i[0]) is a scalar.

> after printing an array, IDL always starts a new line

OK, its an array, but is it acceptable that IDL always starts a new line
after printing an array? Whats the justification for that?

-W.

--
William M Connolley | wmc@bas.ac.uk | http://www.nerc-bas.ac.uk/icd/wmc/
Climate Modeller, British Antarctic Survey | Disclaimer: I speak for myself
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Odd string/index problem
Next Topic: Re: Convolution of Stick Spectra

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

Current Time: Sun Nov 29 01:45:50 PST 2020

Total time taken to generate the page: 0.00704 seconds