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

Home » Public Forums » archive » Re: Type conversion error: Unable to convert given STRING to Float.
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: Type conversion error: Unable to convert given STRING to Float. [message #76857 is a reply to message #76759] Tue, 05 July 2011 13:28 Go to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On 7/5/11 1:56 PM, Zac wrote:
> Here's the solution, convert the integer to a string before inserting
> into the file name:
>
> layr=strcompress(string(lay +1), /REMOVE_ALL)
>
> Open_Device, /ps, /Color, filename=''+outdir+'/emissions_'+sim
> +'_air_level'+layr+'_'+pol+'.ps'
> tvmap, air_pl, lon, lat, BLACK=1, NColors=225, Bottom = 20, /coasts, $
> Title='Layer '+layr+' Aircraft '+pol+' Emissions - '+simtitle,$
>

Here's the two ways I end up using to do this. The quick and easy way:

layr = strtrim(lay + 1, 2)

STRTRIM will convert a number type to a string and also remove
whitespace, here the "2" indicates to remove leading and trailing
whitespace.

Or I might do something like this:

filename = string(outdir, sim, lay + 1, pol, $
format='(%"%s/emissions_%s_air_level%d_%s.ps")')

You can also use Fortran style format codes, I am just more familiar
with the C ones.

Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL, A Guide to Learning IDL: http://modernidl.idldev.com
Research Mathematician
Tech-X Corporation
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Type conversion error: Unable to convert given STRING to Float.
Next Topic: North American Regional Reanalysis (NARR) projection

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

Current Time: Fri Oct 10 01:24:29 PDT 2025

Total time taken to generate the page: 0.47660 seconds