[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Odd string/index problem
- Subject: Re: Odd string/index problem
- From: marc <m_schellens(at)hotmail.com>
- Date: Thu, 14 Sep 2000 17:49:58 +0900
- Newsgroups: comp.lang.idl-pvwave
- Organization: Institute of Physical & Chemical Research (RIKEN) Saitama,Japan
- References: <39bfc95b.0@news.nwl.ac.uk>
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:21389
wmc@bas.ac.uk wrote:
>
> 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
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.
IDL> strings=strarr(10)
IDL> help,strings(1)
<Expression> STRING = ''
IDL> help,strings([1])
<Expression> STRING = Array[1]
after printing an array, IDL always starts a new line
cheers,
:-) marc