Re: printf formatting [message #44623] |
Thu, 30 June 2005 09:41 |
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 #44625 is a reply to message #44624] |
Thu, 30 June 2005 09:24  |
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  |
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  |
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.
|
|
|