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

Home » Public Forums » archive » Adding two strings together
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: Adding two strings together [message #92325 is a reply to message #92322] Tue, 17 November 2015 19:05 Go to previous messageGo to previous message
Jim  Pendleton is currently offline  Jim Pendleton
Messages: 165
Registered: November 2011
Senior Member
On Tuesday, November 17, 2015 at 7:36:30 PM UTC-7, Wayana Dolan wrote:
> So I'm having a devil of a time with something that should be easy.
>
> So I want the end product to look like 'Run07656_Seq0001_Scan012', for every scan in a file I have
> So I put the following in a loop for all of the scans
> x='Run0'+string(variable1)+'_Seq0001_Scan'+string(variable2)
> where variable 1 is the run (ex. 7657), and variable 2 is the scan (ex. 012).
>
> But for some reason they all print out like 'Run0 7656_Seq0001_Scan012'
>
>
> How so I make it so there is no space between the 0 and the 7?
>
> Please help!

When numbers are converted to strings by default using the STRING function, they generally include leading spaces. The traditional way around this is to call the STRTRIM() function, for example STRTRIM(variable1, 2)

If you're running 8.4 or later, I encourage more modern syntax, for example
IDL> x='Run0'+variable1.tostring()+'_Seq0001_Scan'+variable2.tost ring()
IDL> x
Run012345_Seq0001_Scan345

The .tostring() static method on IDL_Variable types implies trimming of both leading and trailing blanks.

For more on static methods, see http://www.exelisvis.com/docs/IDL_Variable.html

Jim P.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Combining two strings
Next Topic: Transparent overlay in postscript cgimage

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

Current Time: Wed Oct 08 15:13:56 PDT 2025

Total time taken to generate the page: 0.00489 seconds