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

Home » Public Forums » archive » Re: Appending Numbers to Strings in IDL
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: Appending Numbers to Strings in IDL [message #48989 is a reply to message #48988] Mon, 05 June 2006 14:57 Go to previous messageGo to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
toddbranch wrote:
> Hi everyone,
>
> I'm new to IDL, and have only been using it for two weeks. I bought
> Liam Gumley's book and it has been quite helpful so far. The program
> I'm writing requires me to identify different objects within an image.
> Since there may be more than one, I append a variable number to the end
> of the file name string to differentiate between objects.
>
> I know that you can append numbers to a string like this:
> string+string(variable)
>
> But, that leaves a lot of whitespace in front of the number. Is there
> a way to eliminate this whitespace?
> I want it to work like this:
> string+string(variable)=stringvariable, not string variable

you can do

stringvar+strtrim(variable,2)

with variable = 1, 2, 3, 4,...... to give you something like

blah1
blah2
blah3
...
blah10
...
blah127
...etc

or

stringvar+string(variable,format='(i4.4)')

to do stuff like

blah0001
blah0002
blah0003
...
blah0010
...
blah0127
...etc

In the latter case, variable must be < 10000.

paulv


--
Paul van Delst Ride lots.
CIMSS @ NOAA/NCEP/EMC Eddy Merckx
Ph: (301)763-8000 x7748
Fax:(301)763-8545
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: idl license installation under debian sarge amd64
Next Topic: .Reset_Session in a script

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

Current Time: Thu Oct 09 20:01:46 PDT 2025

Total time taken to generate the page: 0.24302 seconds