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

Home » Public Forums » archive » Re: Removing the blanks between elements in a string array
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Removing the blanks between elements in a string array [message #69711] Fri, 29 January 2010 20:53
sulli.jj is currently offline  sulli.jj
Messages: 3
Registered: July 2009
Junior Member
On Jan 29, 9:46 pm, pp <pp.pente...@gmail.com> wrote:
> On Jan 30, 2:31 am, "sulli.jj" <sulli...@gmail.com> wrote:
>
>
>
>
>
>> Does anyone know a easy to way to print out an array with no blanks at
>> all?
>
>> I have an array of strings like
>> a = [['  cat,','d o g,','bi    rd   ' ],[' 1.23,   ',' 4.  56,','
>> 7.89   ']]
>
>> print, a
>>   cat, d o g, bi    rd
>>  1.23,     4.  56,  7.89
>
>> I can remove most of the spaces with,
>
>> print, STRCOMPRESS(a, /REMOVE_ALL)
>> cat, dog, bird
>> 1.23, 4.56, 7.89
>
> There are no blanks in the array from strcompress with remove_all. The
> spaces between elements are put there by print's default format.
>
> Two ways to get what you want are
>
> print,strcompress(a,/remove_all),format='(3A0)'
>
> print,strjoin(strcompress(a,/remove_all)),format='(A0)'- Hide quoted text -
>
> - Show quoted text -

Ah, that makes more sense. Thanks for your help!
Re: Removing the blanks between elements in a string array [message #69712 is a reply to message #69711] Fri, 29 January 2010 20:46 Go to previous message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
On Jan 30, 2:31 am, "sulli.jj" <sulli...@gmail.com> wrote:
> Does anyone know a easy to way to print out an array with no blanks at
> all?
>
> I have an array of strings like
> a = [['  cat,','d o g,','bi    rd   ' ],[' 1.23,   ',' 4.  56,','
> 7.89   ']]
>
> print, a
>   cat, d o g, bi    rd
>  1.23,     4.  56,  7.89
>
> I can remove most of the spaces with,
>
> print, STRCOMPRESS(a, /REMOVE_ALL)
> cat, dog, bird
> 1.23, 4.56, 7.89
>

There are no blanks in the array from strcompress with remove_all. The
spaces between elements are put there by print's default format.

Two ways to get what you want are

print,strcompress(a,/remove_all),format='(3A0)'

print,strjoin(strcompress(a,/remove_all)),format='(A0)'
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Removing the blanks between elements in a string array
Next Topic: Simple question about the '>' sign.

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

Current Time: Wed Oct 08 11:35:17 PDT 2025

Total time taken to generate the page: 0.00657 seconds