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

Home » Public Forums » archive » Re: 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
Re: Odd string/index problem [message #21675] Thu, 14 September 2000 00:00
Martin Schultz is currently offline  Martin Schultz
Messages: 515
Registered: August 1997
Senior Member
wmc@bas.ac.uk wrote:
>
> Can someone explain this to me:
>
> wmc> a='stoat'
> wmc> print,a(),'>'
> 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
> print,strings(i)
>
> but why?
>
> -W.
>

To make sure things get written on one line you should either
concatenate the strings ('+') or use a format specifier.

print,a[[0]]+'>' gives you what you want as does
print,a[[0]],'>',format='(2A)' or print,a[[0]],format='(A,">")'. On
the other hand, even print,a[0],'>' will break the line if a is too
long. Example: a=string(bytarr(100)+64B) & print,a[0],'>' (whether
the number is 100 or something greater depends on your display window
width).

Cheers,
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 #21676 is a reply to message #21675] Thu, 14 September 2000 00:00 Go to previous message
marc schellens[1] is currently offline  marc schellens[1]
Messages: 183
Registered: January 2000
Senior Member
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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Quick array question
Next Topic: Odd string/index problem

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

Current Time: Wed Oct 08 19:55:41 PDT 2025

Total time taken to generate the page: 0.00565 seconds