Re: PRINTF format statement [message #83681] |
Fri, 29 March 2013 07:33  |
Michael Galloy
Messages: 1114 Registered: April 2006
|
Senior Member |
|
|
On 3/28/13 8:20 pm, Phillip Bitzer wrote:
> Well, that's exactly how I would've done it. In fact,
>
> IDL> this_gmag = '12.399'
> IDL> PRINT, '<dt>g Mag:</dt><dd>'+this_gmag+'</dd>'
> <dt>g Mag:</dt><dd>12.399</dd>
> IDL> OPENW, lun, 'test.txt', /get_lun
> IDL> PRINTF, lun, '<dt>g Mag:</dt><dd>'+this_gmag+'</dd>'
> IDL> FREE_LUN, lun
>
> works for me. I'm guessing the text file written by IDL is correct (i.e., all one line) but the HTML is formatting the problem. But, using the example at
>
> http://www.w3schools.com/tags/tag_dt.asp
>
> seems to indicate this is the expected HTML output. In fact, the <dt> is for a definition list. Perhaps you want/need a different tag?
>
By the way, I have a template class which is very handy for doing much
of this type of stuff.
For example,
template = obj_new('MGffTemplate', 'template.tt')
template->process, { this_gmag: strtrim(12.399, 2) }, 'template.html'
obj_destroy, template
In the template.tt, would be:
<dt>g Mag:</dt><dd>[% this_gmag %]</dd>
In your small example above, it's not hard to use PRINTF, but if you are
generating an entire HTML file, it's pretty painful. The template syntax
also allows FOR loops, IF statements, etc.
Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com)
Research Mathematician
Tech-X Corporation
|
|
|