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

Home » Public Forums » archive » Re: Printing in one line
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: Printing in one line [message #70449] Mon, 12 April 2010 20:45
Ive Goncalves is currently offline  Ive Goncalves
Messages: 1
Registered: April 2010
Junior Member
On Apr 12, 5:05 pm, fgg <fabioguimaraesgoncal...@gmail.com> wrote:
> Hi,
>
> Here's an easy one. I have an array[5], y:
>
> IDL> print, y
> data = 1 2 3
>
> and I'd like to make IDL print:
>
> data = [1, 2, 3]
>
> When I try:
> IDL> m = n_elements(y)
> IDL> print, y[0:1], '[', y[2:m-2]+',', y[m-1] + ']'
>
> IDL prints:
> fabio =
> [
> 1, 2,
> 3]
>
> How can I get this result in just one line (instead of 4)?
>
> Thanks in advance,
> Fabio

Thanks a lot!
Re: Printing in one line [message #70452 is a reply to message #70449] Mon, 12 April 2010 17:27 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On Apr 12, 8:08 pm, fgg <fabioguimaraesgoncal...@gmail.com> wrote:
> On Apr 12, 5:05 pm, fgg <fabioguimaraesgoncal...@gmail.com> wrote:
>
>
>
>> Hi,
>
>> Here's an easy one. I have an array[5], y:
>
>> IDL> print, y
>> data = 1 2 3
>
>> and I'd like to make IDL print:
>
>> data = [1, 2, 3]
>
>> When I try:
>> IDL> m = n_elements(y)
>> IDL> print, y[0:1], '[', y[2:m-2]+',', y[m-1] + ']'
>
>> IDL prints:
>> fabio =
>> [
>> 1, 2,
>> 3]
>
>> How can I get this result in just one line (instead of 4)?
>
>> Thanks in advance,
>> Fabio
>
> Sorry... actually IDL prints:
> data =
> [
> 1, 2,
> 3]

What you want is a FORMAT keyword. This does the trick for a three-
element array...

IDL> print, y, format='("[",3(I0,:,","),$)' & print, ']'
[1,2,3]
Re: Printing in one line [message #70453 is a reply to message #70452] Mon, 12 April 2010 17:13 Go to previous message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
On Apr 12, 9:08 pm, fgg <fabioguimaraesgoncal...@gmail.com> wrote:
>> Here's an easy one. I have an array[5], y:
>
>> IDL> print, y
>> data = 1 2 3
>
>> and I'd like to make IDL print:
>
>> data = [1, 2, 3]


print,strjoin(y[0:1],' ')+' ['+strjoin(y[2:*],', ')+']'
Re: Printing in one line [message #70454 is a reply to message #70453] Mon, 12 April 2010 17:08 Go to previous message
fgg is currently offline  fgg
Messages: 67
Registered: April 2010
Member
On Apr 12, 5:05 pm, fgg <fabioguimaraesgoncal...@gmail.com> wrote:
> Hi,
>
> Here's an easy one. I have an array[5], y:
>
> IDL> print, y
> data = 1 2 3
>
> and I'd like to make IDL print:
>
> data = [1, 2, 3]
>
> When I try:
> IDL> m = n_elements(y)
> IDL> print, y[0:1], '[', y[2:m-2]+',', y[m-1] + ']'
>
> IDL prints:
> fabio =
> [
> 1, 2,
> 3]
>
> How can I get this result in just one line (instead of 4)?
>
> Thanks in advance,
> Fabio

Sorry... actually IDL prints:
data =
[
1, 2,
3]
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: IMAGE_STATISTICS for 3D Array
Next Topic: IDL license costs in europe?

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

Current Time: Wed Oct 08 11:39:57 PDT 2025

Total time taken to generate the page: 0.00941 seconds