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

Home » Public Forums » archive » string to array conversion
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 to array conversion [message #21136 is a reply to message #21005] Fri, 11 August 2000 00:00 Go to previous messageGo to previous message
Martin Schultz is currently offline  Martin Schultz
Messages: 515
Registered: August 1997
Senior Member
Karsten Schmidt wrote:
>
> Hi Alex, thanks for your answer,
> I want to change the stringlength or produce new strings (delete and add
> some words), example:
>
> a=string('llllllllllllllllllllllllllllllllllllllllllllllllll llllllllllllllllllllllllllllllllllllllllllllllllllllllllllll llllllllllllllllllllllllllllllllllllllllllllllllllllllllllll llllllllllllllllllllllllllllllllllllllllllllllllllllllllllll llllllllllllllllllllllllllllllllllllllllll')
>
> print,strlen(a)
> 272
> help,a
> A STRING =
> 'lllllllllllllllllllllllllllllllllllllllllllll'...
> that's allright,
> but if I write:
> word=string('long strings are my problem')
> together=string(word,word,word,word,word,word,word)
> print,strlen(together)
> 162 27
> help,togehter ==> TOGETHER STRING = Array
>
> What's happen and how can I stop it ?
>
> Karsten

Hallo Karsten,

another possible solution is the format option for the string
function, see example below.

Cheers,
Martin

; generate two example strings of 300 byte length each
b=bytarr(300)+65B
c=bytarr(300)+69B
bs=string(b)
help,bs
; BS STRING =
'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'...
print,strlen(bs)
; 300
cs=string(c)

; if you use only the string function, IDL will generate a string array
ds=string(bs,cs)
help,ds & print,strlen(ds)
; DS STRING = Array[2]
; 300 300

; however, if you add the format option, you can concetanate the strings
ds=string(bs,cs,format='(A,A)')
help,ds & print,strlen(ds)
; DS STRING =
'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'...
;
600

--
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
[[ 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 [[
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: A related question...
Next Topic: Reading in text data

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

Current Time: Sun Oct 12 09:43:27 PDT 2025

Total time taken to generate the page: 0.24353 seconds