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 #52020 is a reply to message #20144] Fri, 22 December 2006 00:44 Go to previous messageGo to previous message
Erik[1] is currently offline  Erik[1]
Messages: 23
Registered: December 2006
Junior Member
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.

Have a nice Christmas :P
[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: Wed Oct 15 10:42:46 PDT 2025

Total time taken to generate the page: 1.91827 seconds