Simple number formatting problem [message #21023] |
Wed, 02 August 2000 00:00  |
Simon de Vet
Messages: 36 Registered: May 2000
|
Member |
|
|
Trivial problem, no doubt, but I've never been able to get my brane
around formatting options.
I have a list of files, with the extension .01, .02, .03 ... .12. The
preceding portion is indentical in all cases.
I'd like to be able to load these in a loop, but I first need to convert
the counter value into this format.
My current, and very ugly, technique is to have an array filled with
['01', '02', ... '12'], and then reference the appropriate entry. It
works, but I don't like it.
Any ideas?
Simon
|
|
|
Re: Simple number formatting problem [message #21038 is a reply to message #21023] |
Fri, 04 August 2000 00:00  |
Paul van Delst
Messages: 364 Registered: March 1997
|
Senior Member |
|
|
Craig Markwardt wrote:
>
> "Mark Hadfield" <m.hadfield@niwa.cri.nz> writes:
>
>> "Luis Alonso" <luis.alonso@uv.es> wrote in message
>> news:8mbrv6$ra0$1@peque.uv.es...
>>>> p.s. F95 has a new formatting option, i0, which would print out 1 as
>>>> "1", 10 as "10" etc. i.e. the leading blanks removed. Maybe this should
>>>> go on a future IDL feature request list....? :o)
>>>
>>> strtrim do remove leading blanks. and it would not be longer to write than
>>> the Format thing.
>>
>> Yes, but removal of leading blanks via a format code would be handy for use
>> with TICKFORMAT.
>
> Not sure what you folks are arguing about. IDL has had the I0 format
> code for as long as I've known, and does exactly what you want!
>
> Craig
>
> Example:
> IDL> print, 1, format='("<",I0,">")'
> <1>
> IDL> print, 10, format='("<",I0,">")'
> <10>
Aww, crap. Thanks for pointing this out. RTFM shure helps. <insert
embarrassed grin right here>
paulv
--
Paul van Delst Ph: (301) 763-8000 x7274
CIMSS @ NOAA/NCEP Fax: (301) 763-8545
Rm.202, 5200 Auth Rd. Email: pvandelst@ncep.noaa.gov
Camp Springs MD 20746
|
|
|
Re: Simple number formatting problem [message #21048 is a reply to message #21023] |
Fri, 04 August 2000 00:00  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
"Mark Hadfield" <m.hadfield@niwa.cri.nz> writes:
> "Luis Alonso" <luis.alonso@uv.es> wrote in message
> news:8mbrv6$ra0$1@peque.uv.es...
>>> p.s. F95 has a new formatting option, i0, which would print out 1 as
>>> "1", 10 as "10" etc. i.e. the leading blanks removed. Maybe this should
>>> go on a future IDL feature request list....? :o)
>>
>> strtrim do remove leading blanks. and it would not be longer to write than
>> the Format thing.
>
> Yes, but removal of leading blanks via a format code would be handy for use
> with TICKFORMAT.
Not sure what you folks are arguing about. IDL has had the I0 format
code for as long as I've known, and does exactly what you want!
Craig
Example:
IDL> print, 1, format='("<",I0,">")'
<1>
IDL> print, 10, format='("<",I0,">")'
<10>
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|
Re: Simple number formatting problem [message #21059 is a reply to message #21023] |
Fri, 04 August 2000 00:00  |
Mark Hadfield
Messages: 783 Registered: May 1995
|
Senior Member |
|
|
"Luis Alonso" <luis.alonso@uv.es> wrote in message
news:8mbrv6$ra0$1@peque.uv.es...
>> p.s. F95 has a new formatting option, i0, which would print out 1 as
>> "1", 10 as "10" etc. i.e. the leading blanks removed. Maybe this should
>> go on a future IDL feature request list....? :o)
>
> strtrim do remove leading blanks. and it would not be longer to write than
> the Format thing.
Yes, but removal of leading blanks via a format code would be handy for use
with TICKFORMAT.
---
Mark Hadfield
m.hadfield@niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield/
National Institute for Water and Atmospheric Research
PO Box 14-901, Wellington, New Zealand
|
|
|