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

Home » Public Forums » archive » Re: Convert Integer to Text
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: Convert Integer to Text [message #25051] Mon, 14 May 2001 05:24 Go to previous message
Martin Schultz is currently offline  Martin Schultz
Messages: 515
Registered: August 1997
Senior Member
Dan Blair <vze2p88d@verizon.net> writes:

> Mark Hadfield wrote:
>
>> From: ""Mark Hadfield"" <m.hadfield@niwa.cri.nz>
>>
>>> You can add the prefix and suffix via the "+" operator like this...
>>>
>>> name = 'MC'+string(index,format='(I3.3)')+'.dcm'
>>>
>>> or within the format specifier like this...
>>>
>>> name = string(index,format='("MC",I3.3,".dcm"')'
>>
>> Of course you can also use printf-style format codes (new to IDL 5.4) like
>> this
>>
>> name = string(index,format='(%"MC%3.3d.dcm")')
>>
>> I suppose there must be somebody out there who actually *uses* this stuff?
>>
>> ---
>> Mark Hadfield

> A freind of mine wrote a nice thing for just this application. It's a
> function called
> padnumstring.pro
>
> here it is
>
> repeat begin
> if strlen(numstring) lt length then numstring='0'+numstring
> endrep until strlen(numstring) eq length

Not to blame you or your friend, but Mark's solution using the format qualifier is far superior and faster, too. You shouldn't use a loop in IDL when you can avoid it as easily as here.

Martin


--
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
[[ Dr. Martin Schultz Max-Planck-Institut fuer Meteorologie [[
[[ Bundesstr. 55, 20146 Hamburg [[
[[ phone: +49 40 41173-308 [[
[[ fax: +49 40 41173-298 [[
[[ martin.schultz@dkrz.de [[
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Determining circularity
Next Topic: Can't READ_DICOM without DIALOG_PICKFILE

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

Current Time: Fri Oct 10 10:14:01 PDT 2025

Total time taken to generate the page: 0.00778 seconds