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

Home » Public Forums » archive » STRMID question
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
STRMID question [message #26279] Mon, 20 August 2001 10:13 Go to previous message
Paul van Delst is currently offline  Paul van Delst
Messages: 364
Registered: March 1997
Senior Member
Hello,

I have a "question" about the output of STRMID. Consider the following:

Given an input string array:

IDL> s='_'+strtrim(10L^lindgen(10),2)+'.'
IDL> print, s
_1. _10. _100. _1000. _10000. _100000. _1000000. _10000000. _100000000. _1000000000.

I search for the "_" and "." characters (I do a reverse search as there may be other "_"
or "." in the string before the last set):

IDL> delim1 = STRPOS( s, '_', /REVERSE_SEARCH ) + 1
IDL> delim2 = STRPOS( s, '.', /REVERSE_SEARCH ) - 1

So now I want to extract out the substrings from the string array delimited by delim1 and
delim2:

IDL> help, STRMID( s, delim1, delim2-delim1+1 )
<Expression> STRING = Array[10, 10]

How come I get a 2-D array output? I can sort of see how that _could_ happen since delim1
and delim2 are both vectors so the output:

IDL> print, STRMID( s, delim1, delim2-delim1+1 )
1 1. 1. 1. 1. 1. 1. 1. 1. 1.
1 10 10. 10. 10. 10. 10. 10. 10. 10.
1 10 100 100. 100. 100. 100. 100. 100. 100.
1 10 100 1000 1000. 1000. 1000. 1000. 1000. 1000.
1 10 100 1000 10000 10000. 10000. 10000. 10000. 10000.
1 10 100 1000 10000 100000 100000. 100000. 100000. 100000.
1 10 100 1000 10000 100000 1000000 1000000. 1000000. 1000000.
1 10 100 1000 10000 100000 1000000 10000000 10000000. 10000000.
1 10 100 1000 10000 100000 1000000 10000000 100000000 100000000.
1 10 100 1000 10000 100000 1000000 10000000 100000000 1000000000

sort of makes sense, but does it make sense to anyone that it _should_ happen?? It's not a
big deal since I can do a

IDL> si=STRMID( s, delim1, delim2-delim1+1 )
IDL> i=indgen(10)
IDL> print, si[i,i]
1 10 100 1000 10000 100000 1000000 10000000 100000000 1000000000

to extract the diagonal, but the original result sorta threw me and I haven't yet
recovered <whimper>.

paulv

--
Paul van Delst A little learning is a dangerous thing;
CIMSS @ NOAA/NCEP Drink deep, or taste not the Pierian spring;
Ph: (301)763-8000 x7274 There shallow draughts intoxicate the brain,
Fax:(301)763-8545 And drinking largely sobers us again.
Alexander Pope.
[Message index]
 
Read Message
Read Message
Previous Topic: Re: GET_SCREEN_SIZE in Windows
Next Topic: Re: problems with VELOVECT

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

Current Time: Wed Oct 08 15:54:27 PDT 2025

Total time taken to generate the page: 0.00405 seconds