Re: IDL string trim [message #61138] |
Mon, 07 July 2008 07:43  |
mchinand
Messages: 66 Registered: September 1996
|
Member |
|
|
In article <MPG.22daffe956a87f7598a3cb@news.frii.com>,
David Fanning <news@dfanning.com> wrote:
> RussellGrew writes:
>
>> This may not be the most elegant solution, but you can look at the
>> size of k and add an extra zero to the string manually.
>>
>> eg for the variable 'tmp' being slotted into the filename,
>>
>> if k lt 10. then tmp = '0' + strtrim(string(k), 2) else k =
>> strtrim(string(k), 2)
>>
>> I shall sit here and wait to be shot down by a more elegant solution.
>
> I think this might be the elegant solution you are looking for:
>
> strVal = String(k, Format='(i2.2)')
>
> Cheers,
>
> David
I usually use:
String(k, format='(I02)')
which seems a little more intuitive (the zero indicating to zero-pad the string) but produces the same results as David's.
--Mike
--
Michael Chinander
m-chinander@uchicago.edu
Department of Radiology
University of Chicago
|
|
|
|
|
|
|
Re: IDL string trim [message #61213 is a reply to message #61138] |
Tue, 08 July 2008 21:37  |
raghuram
Messages: 32 Registered: February 2008
|
Member |
|
|
On Jul 7, 7:43 am, mchin...@midway.uchicago.edu (Mike Chinander)
wrote:
> In article <MPG.22daffe956a87f7598a...@news.frii.com>,
> David Fanning <n...@dfanning.com> wrote:
>
>
>
>
>
>> RussellGrew writes:
>
>>> This may not be the most elegant solution, but you can look at the
>>> size of k and add an extra zero to the string manually.
>
>>> eg for the variable 'tmp' being slotted into the filename,
>
>>> if k lt 10. then tmp = '0' + strtrim(string(k), 2) else k =
>>> strtrim(string(k), 2)
>
>>> I shall sit here and wait to be shot down by a more elegant solution.
>
>> I think this might be the elegant solution you are looking for:
>
>> strVal = String(k, Format='(i2.2)')
>
>> Cheers,
>
>> David
>
> I usually use:
>
> String(k, format='(I02)')
>
> which seems a little more intuitive (the zero indicating to zero-pad the string) but produces the same results as David's.
>
> --Mike
>
> --
> Michael Chinander
> m-chinan...@uchicago.edu
> Department of Radiology
> University of Chicago- Hide quoted text -
>
> - Show quoted text -
Hi all,
Thanks a lot. It works.
Raghu
|
|
|