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

Home » Public Forums » archive » Re: string functions and arrays
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: string functions and arrays [message #50551] Wed, 11 October 2006 11:01 Go to previous message
news.verizon.net is currently offline  news.verizon.net
Messages: 47
Registered: August 2003
Member
greg michael wrote:
> Isn't it odd that STRMID can't operate on a string array? I can get a
> nice set of positions from an array with STRPOS, but can't apply them
> like this...
>
STRMID does operate on string arrays but with a funky syntax. You
can search on "strmid" and "vector" in the archives to see previous
posts on the topic but I'll quote from myself.

"The problem when STRMID was vectorized for V5.3 was that it was made
*too* powerful -- it handles simultaneously both extraction from
multiple strings and multiple extractions from a single string. In
practice, I think the first situation -- extraction from multiple
strings -- is far more common, but has an ugly syntax in the current
STRMID implementation.

The online help describes the vector use of STRMID this way:

"If First_Character or Length is an array, the size of their first
dimension determines how many substrings are extracted from each
element of Expression. We call this the "stride". If both are arrays,
they must have the same stride. If First_Character or Length do not
contain enough elements to process Expression, STRMID automatically
loops back to the beginning as necessary. Excess values are ignored. If
the stride is 1, the result will have the same structure and number of
elements as Expression. If it is greater than 1, the result will have
an additional dimension, with the new first dimension having the same
size as the stride. "

In your example, the call to strmid() needs to be (if there are Npts
values in your array)
strmid(lbl, 0, reform(p-1, 1, npts))

I've thought about writing a wrapper to strmid() that provides an easy
syntax for the common case of single extractions from multiple strings,
but in practice I usually use
http://idlastro.gsfc.nasa.gov/ftp/pro/misc/gettok.pro
to extract strings, (and this includes a vector call to strmid()
internally). --Wayne
[Message index]
 
Read Message
Read Message
Previous Topic: idl syntax validation
Next Topic: _extra

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

Current Time: Wed Oct 22 15:00:45 PDT 2025

Total time taken to generate the page: 0.14785 seconds