[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: string to array conversion



Karsten Schmidt (k.schmidt@vermes.fh-oldenburg.de) writes:

> Hi Alex, thanks for your answer,
> I want to change the stringlength or produce new strings (delete and add
> some words), example:
> 
> a=string('llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll')
> 
> 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[2]
> 
> What's happen and how can I stop it ?

If you want to string words together, you should
use the + sign:

  IDL> word1 = 'Hello '
  IDL> word2 = 'Karsten'
  IDL> word3 = ': How are you?"
  IDL> sentence = word1 + word2 + word3
  IDL> Print, sentence

     Hello Karsten: How are you?

Cheers, 

David

-- 
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155