| Re: writting formatted acsii file [message #36658] |
Thu, 09 October 2003 09:16 |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Francois Leduc writes:
> I have a 13 columns by 5 rows floating array that I want to save in a
> ASCII file. I can use the following command:
>
> openw, 1, 'd:\file.txt'
> printf, 1, FORMAT = '(13(F11.4))', array
> close, 1
>
> My question is: How to replace the 13 value by a variable ?
>
> By doing this:
> a = 13
> printf, 1, FORMAT = '(a(F11.4))', array
>
> I get an error message or the format is not in the proper way.
Try this:
a = 13
myformat = '(' + StrTrim(a,2) + '(F11.4))'
Printf, 1, Fomat=myformat
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
|