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

Home » Public Forums » archive » David: for your book ?
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: David: for your book ? [message #21276 is a reply to message #21233] Wed, 16 August 2000 00:00 Go to previous messageGo to previous message
landsman is currently offline  landsman
Messages: 93
Registered: August 1991
Member
In article <399937D2.8C0A52A2@dkrz.de>,
Martin Schultz <martin.schultz@dkrz.de> wrote:
>
> What would you expect to get out of the following:
>
> test = [ 'dir1/', 'directory2/', 'another_directory/' ]
> print,strmid(test,0,strlen(test)-1)
>
> ??
>
> Well, I at least had expected to get the directory names without the
> trailing '/'.
> But, no!
> help, strmid(test,0,strlen(test)-1)
> reveals that the result is a 3x3 array!!

When IDL added vector capabilities to STRMID in V5.3, they allowed for
both (1) the extraction of multiple substrings from each element of a
string, and (2) having the first character position and substring length
differ for each element of a string array. Unfortunately, adding all
this power has made the syntax awkward. According to the documentation

"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>"

So the solution is to REFORM the string length (or position) array to
two dimensions:

IDL> test = [ 'dir1/', 'directory2/', 'another_directory/']
IDL> print,strmid(test,0,reform( strlen(test)-1, 1, 3) )
===>dir1 directory2 another_directory

By reforming the string length array into a 1 x 3 size, STRMID now knows
to extract only 1 substring from each element of test.

A simple program to extract a string array up to a specified character
using the vector capabilities of STRMID is available at

http://idlastro.gsfc.nasa.gov/ftp/v53/gettok.pro

--Wayne Landsman landsman@mpb.gsfc.nasa.gov


Sent via Deja.com http://www.deja.com/
Before you buy.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Passing function to function called by qromb etc.?
Next Topic: Passing function to function called by qromb etc.?

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

Current Time: Tue Dec 02 19:32:47 PST 2025

Total time taken to generate the page: 0.00238 seconds