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

Home » Public Forums » archive » How to convert (concatenate) a string array to a string scalar?
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: How to convert (concatenate) a string array to a string scalar? [message #19425 is a reply to message #19283] Mon, 13 March 2000 00:00 Go to previous message
Alex Schuster is currently offline  Alex Schuster
Messages: 124
Registered: February 1997
Senior Member
David Fanning wrote:

> Kristian Kjaer (kristian.kjaer@risoe.dk) writes:
>
>> Given
>> numarray=[1342,1347,1355] ;, say, I wan't
>> strscalar='1342,1347,1355' ;, but
>> help,string(numarray)
>> gives: STRING = Array[3]
>> and
>> help,total(string(numarray))
>> gives an error.
>>
>> How to convert (concatenate) a string array to a string scalar?
>
> Now here (I feel pretty darn confident) is the perfect
> opportunity to use a loop in IDL. :-)

BEEEEEP! There's no need for that, here's a function which does what
Kristian wants:

function strconcat, numarray
format = string( '(', n_elements( numarray ), '(I0,', '","))' )
str = string( numarray, format=format )
return, strmid( str, 0, strlen( str ) - 1 )
end

In the example above, the format string which is created inside the
function would be '3(I0,",")' , which tells the STRING routine to take
three integers and add them to the string without leading blanks, but
with a comma between them. The last strmid call only removes the last
comma from the string.

Alex
--
Alex Schuster Wonko@weird.cologne.de PGP Key available
alex@pet.mpin-koeln.mpg.de
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Release of IDL 5.3.1 for Microsoft Windows 95/98/NT/2000
Next Topic: SVDFIT bug?

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

Current Time: Wed Oct 15 13:47:26 PDT 2025

Total time taken to generate the page: 0.94422 seconds