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

Home » Public Forums » archive » Output file with string blanks and float
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Output file with string blanks and float [message #90881 is a reply to message #90880] Mon, 04 May 2015 06:47 Go to previous messageGo to previous message
Matthew Argall is currently offline  Matthew Argall
Messages: 286
Registered: October 2011
Senior Member
Instead of writing a space, simply advance the file pointer to the right.

Take this example

;A line of data
data = [1.0, -1.0, 6.0]

;Search for and remove negative numbers
ipos = where(data ge 0, npos, COMPLEMENT=ineg, NCOMPLEMENT=nneg)
data = data[ipos]

;Create a format code with floats for positive numbers and spaces for negative numbers
fmt = strarr(npos + nneg)
if npos gt 0 then fmt[ipos] = 'f8.2'
if nneg gt 0 then fmt[ineg] = '8x'
fmt = '(' + strjoin(fmt, ',') + ')'

;Results
help, string(data, FORMAT=fmt)
<Expression> STRING = ' 1.00 6.00'
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Mapping southern in Northern map
Next Topic: counting points falling inside a Voronoi cell

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

Current Time: Wed Oct 08 16:12:01 PDT 2025

Total time taken to generate the page: 0.00188 seconds