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

Home » Public Forums » archive » Re: Digits in IDL
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: Digits in IDL [message #67845] Tue, 25 August 2009 23:31
Nusret Sevinç is currently offline  Nusret Sevinç
Messages: 8
Registered: March 2009
Junior Member
On 25 Ağustos, 19:48, pp <pp.pente...@gmail.com> wrote:
> On Aug 25, 1:37 pm, Spon II <christoph.b...@gmail.com> wrote:
>
>> you can do this using format codes, either with PRINT or STRING.
>
>> e.g.
>> print, indgen(12)+1, format='(I2)'
>
> If you want to force the number to always use two digits (with the
> leading 0), you need to use I02 or I2.2, instead of I2. If you want
> the 1 digit numbers to occupy only one character (with no leading 0),
> you can use I0 instead.

That's what I need, thank you pp. Thank you too Chris.

Nusret
Re: Digits in IDL [message #67853 is a reply to message #67845] Tue, 25 August 2009 09:58 Go to previous message
Spon is currently offline  Spon
Messages: 178
Registered: September 2007
Senior Member
On Aug 25, 5:48 pm, pp <pp.pente...@gmail.com> wrote:
> On Aug 25, 1:37 pm, Spon II <christoph.b...@gmail.com> wrote:
>
>> you can do this using format codes, either with PRINT or STRING.
>
>> e.g.
>> print, indgen(12)+1, format='(I2)'
>
> If you want to force the number to always use two digits (with the
> leading 0), you need to use I02 or I2.2, instead of I2. If you want
> the 1 digit numbers to occupy only one character (with no leading 0),
> you can use I0 instead.

Oops, good catch. That should be '(I02)'.
Chris
Re: Digits in IDL [message #67854 is a reply to message #67853] Tue, 25 August 2009 09:48 Go to previous message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
On Aug 25, 1:37 pm, Spon II <christoph.b...@gmail.com> wrote:
> you can do this using format codes, either with PRINT or STRING.
>
> e.g.
> print, indgen(12)+1, format='(I2)'

If you want to force the number to always use two digits (with the
leading 0), you need to use I02 or I2.2, instead of I2. If you want
the 1 digit numbers to occupy only one character (with no leading 0),
you can use I0 instead.
Re: Digits in IDL [message #67855 is a reply to message #67854] Tue, 25 August 2009 09:37 Go to previous message
Spon is currently offline  Spon
Messages: 178
Registered: September 2007
Senior Member
On Aug 25, 4:33 pm, Nusret Sevinç <nusretsev...@gmail.com> wrote:
> Hi there,
>
> I am dealing with a time conversion and I have an easy question. I
> want to display a date in this format: 2009-01-01
>
> I have three distinct arrays for year, month and date. I am trying to
> combine the three arrays in the print section and I have no problem
> with combining. My month and date arrays are like this:
>
>   1
>   2
>   3
>   4
>   5
>   6
>   7
>   8
>   9
> 10
> ...
> When I combine those three arrays, I have this date: 2009- 1- 1  (you
> see, there are 0's missing)
>
> Can you please tell me how to put that zeros there?
> Thanks in advance,
> Nusret

Hi Nusret,

you can do this using format codes, either with PRINT or STRING.

e.g.
print, indgen(12)+1, format='(I2)'

Regards,
Chris
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Speed-up of code
Next Topic: Re: data criteria

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

Current Time: Wed Oct 08 19:45:57 PDT 2025

Total time taken to generate the page: 0.00609 seconds