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

Home » Public Forums » archive » Re: printf formatting
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: printf formatting [message #44623] Thu, 30 June 2005 09:41
brian0918 is currently offline  brian0918
Messages: 5
Registered: June 2005
Junior Member
Here's my working version:

printf,1,format='(1((1x,3(f3.1,1x)),:,1x,"\"),$)',data(0:*)
printf,1," \"


The 1(),$ prevents it from printing a carriage return when it
finishes. I'm not sure if the 1 is necessary, but it works.
Re: printf formatting [message #44624 is a reply to message #44623] Thu, 30 June 2005 09:27 Go to previous message
brian0918 is currently offline  brian0918
Messages: 5
Registered: June 2005
Junior Member
Nevermind, I understand now. This also solves another problem I was
going to ask. Thanks!
Re: printf formatting [message #44625 is a reply to message #44624] Thu, 30 June 2005 09:24 Go to previous message
brian0918 is currently offline  brian0918
Messages: 5
Registered: June 2005
Junior Member
How could the : be implemented though? It would have to terminate
after printing an unknown number of lines with a \ at the end of them.
Can you provide an example?

Thanks.
Re: printf formatting [message #44626 is a reply to message #44625] Thu, 30 June 2005 09:04 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
"brian0918" <brian0918@gmail.com> writes:
> Alright, I found a way to do it, but it's not that pretty. I have it
> check if (the total size of the array) mod (number of columns per row)
> = 0, and if it does, then it does that command, but if it doesn't equal
> 0, then:
>
> printf,1,format='(1((1x,3(f3.1,1x)),1x,"\"),$)',data(0:*)
> printf,1," \"
>
>
> If anyone sees any problems with this, or if you know of a much easier
> way to do this, please let me know.

To avoid the comparison, couldn't you use the ':' format code to
terminate the output, and then always append the '\' with a separate
command?

Anyway, your solution doesn't seem that ugly to me. Complex
formatting requires complex solutions.

Good luck,
Craig


--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
Re: printf formatting [message #44627 is a reply to message #44626] Thu, 30 June 2005 08:54 Go to previous message
brian0918 is currently offline  brian0918
Messages: 5
Registered: June 2005
Junior Member
Alright, I found a way to do it, but it's not that pretty. I have it
check if (the total size of the array) mod (number of columns per row)
= 0, and if it does, then it does that command, but if it doesn't equal
0, then:

printf,1,format='(1((1x,3(f3.1,1x)),1x,"\"),$)',data(0:*)
printf,1," \"


If anyone sees any problems with this, or if you know of a much easier
way to do this, please let me know.

Thanks.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Map_Grid
Next Topic: Map_grid options

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

Current Time: Sat Oct 11 11:50:18 PDT 2025

Total time taken to generate the page: 0.24760 seconds