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 #52021 is a reply to message #20144] Fri, 22 December 2006 00:39 Go to previous message
mmeron is currently offline  mmeron
Messages: 44
Registered: October 2003
Member
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"
[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 04:35:44 PST 2025

Total time taken to generate the page: 0.88283 seconds