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

Home » Public Forums » archive » Re: Dynamic format.
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: Dynamic format. [message #50293] Tue, 26 September 2006 16:12
Hanford is currently offline  Hanford
Messages: 2
Registered: September 2006
Junior Member
Thanks Ben. Worked well.

Hanford.

Ben Tupper wrote:
> hanford.deglint@gmail.com wrote:
>> Dynamic format.
>>
>> Hello.
>>
>> The following little program fails.
>>
>> pro temp
>>
>> cols = 120
>> a = indgen(cols,12)
>>
>> openw, /get_lun, unit, '~/temp/whatever.dat'
>> printf, unit, a, fomat = '(colsI)'
>>
>> free_lun, unit
>>
>> end
>>
>> This is not working. It seems that format requires a number, it does
>> not like cols. Is there a way to format this text in such a way the
>> carriage return is at the end of the row. Using 'printf, unit, a'
>> causes the carriage return to be interspersed and at the end.
>>
>
> Hello,
>
> Your trying to smush an integer into a string without converting it
> first. I think you want something like,
>
> printf,unit,a, format='(' + STRTRIM(cols,2) + 'I)'
>
> which converts cols to STRING first.
>
> I am not sure if it is an issue for you but you may need to specify the
> WIDTH keyword to OPENW. Sometimes the default width isn't quite wide
> enough.
>
> Cheers,
> Ben
Re: Dynamic format. [message #50296 is a reply to message #50293] Tue, 26 September 2006 14:16 Go to previous message
btt is currently offline  btt
Messages: 345
Registered: December 2000
Senior Member
hanford.deglint@gmail.com wrote:
> Dynamic format.
>
> Hello.
>
> The following little program fails.
>
> pro temp
>
> cols = 120
> a = indgen(cols,12)
>
> openw, /get_lun, unit, '~/temp/whatever.dat'
> printf, unit, a, fomat = '(colsI)'
>
> free_lun, unit
>
> end
>
> This is not working. It seems that format requires a number, it does
> not like cols. Is there a way to format this text in such a way the
> carriage return is at the end of the row. Using 'printf, unit, a'
> causes the carriage return to be interspersed and at the end.
>

Hello,

Your trying to smush an integer into a string without converting it
first. I think you want something like,

printf,unit,a, format='(' + STRTRIM(cols,2) + 'I)'

which converts cols to STRING first.

I am not sure if it is an issue for you but you may need to specify the
WIDTH keyword to OPENW. Sometimes the default width isn't quite wide
enough.

Cheers,
Ben
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Like SPLINE but does not go through all points
Next Topic: how to keep an image object in the window?

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

Current Time: Wed Oct 08 11:44:50 PDT 2025

Total time taken to generate the page: 0.00855 seconds