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

Home » Public Forums » archive » Formatting strings to coordinates
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: Formatting string [message #52019 is a reply to message #20144] Fri, 22 December 2006 00:56 Go to previous messageGo to previous message
mmeron is currently offline  mmeron
Messages: 44
Registered: October 2003
Member
In article <1166777066.340722.90420@a3g2000cwd.googlegroups.com>, "Erik" <janssen.e@gmail.com> writes:
> mme...@cars3.uchicago.edu wrote:
>> In article <1166775977.998673.214070@42g2000cwt.googlegroups.com>, "Erik" <janssen.e@gmail.com> writes:
>>> Hi everyone,
>>>
>>> I have a question about formatting a string in IDL. I have a var-string
>>> which contains an integer value (like this '12' or '312').
>>> Unfortunately I need a string with four characters. If the integer
>>> value isn't four characters long, I want some 0's in front of it (like
>>> this; '0012' or '0312'). Is there any simple way of doing this, without
>>> parsing the string?
>>>
>> Sure. Assuming your var_string is called var, you get the padded one
>> by
>>
>> newvar = strmid('0000'+var,3,4,/reverse)
>>
>> var can be an array in this expression.
>>
>> Mati Meron | "When you argue with a fool,
>> meron@cars.uchicago.edu | chances are he is doing just the same"
>
>
> Thanks! It works! Never knew that strmid has such capabilitys. I only
> thought it was used for cutting strings.
>
Well, in principle yes, but by combining padding and cutting you can
do quite a lot.

> Have a nice Christmas :P
>
Thanks, you too.

Mati Meron | "When you argue with a fool,
meron@cars.uchicago.edu | chances are he is doing just the same"
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: ENVI and the IDL Virtual Machine
Next Topic: Re: XVOLUME in batch?

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

Current Time: Sun Nov 30 22:00:05 PST 2025

Total time taken to generate the page: 2.15234 seconds