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

Home » Public Forums » archive » Re: Determining a safe variable name from a string
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Determining a safe variable name from a string [message #51013] Wed, 01 November 2006 00:00
Ben Panter is currently offline  Ben Panter
Messages: 102
Registered: July 2003
Senior Member
Wayne Landsman wrote:
> Ben Panter wrote:
>
>> I've already written something similar which I can butcher, but I'm
>> sure there was an IDL routine that did this already?
>
> Check out the IDL_VALIDNAME function with the /CONVERT_ALL option.
> --Wayne
>

Thanks Wayne - that's the one.

--
Ben Panter, Edinburgh, UK.
Email false, http://www.benpanter.co.uk
or you could try ben at ^^^^^^^^^^^^^^^
Re: Determining a safe variable name from a string [message #51014 is a reply to message #51013] Wed, 01 November 2006 00:00 Go to previous message
Ben Panter is currently offline  Ben Panter
Messages: 102
Registered: July 2003
Senior Member
David Fanning wrote:

> I think you must be talking about that wonderful (nee miraculous)
> function Stregex. Combined with StrSplit and StrJoin, fabulous
> things can be done in a single line!

Cheers David - it was the one that Wayne points to that I was after but
I agree regexp's are incredibly useful, if you can only remember the
syntax...

> P.S. Have you moved back to Edinburgh? Is your apartment
> big enough for a visitor? :-)

Yes, and certainly! I'm still an astronomer, but I'm also working in a
collaboration looking at medical imaging too. I'm finding it very odd
dealing with images where the subject is close enough to ask to move
round a bit, you just don't get that co-operation from galaxies...

Ben

--
Ben Panter, Edinburgh, UK.
Email false, http://www.benpanter.co.uk
or you could try ben at ^^^^^^^^^^^^^^^
Re: Determining a safe variable name from a string [message #51029 is a reply to message #51014] Tue, 31 October 2006 11:19 Go to previous message
news.verizon.net is currently offline  news.verizon.net
Messages: 47
Registered: August 2003
Member
Ben Panter wrote:

> I've already written something similar which I can butcher, but I'm
> sure there was an IDL routine that did this already?

Check out the IDL_VALIDNAME function with the /CONVERT_ALL option.
--Wayne
Re: Determining a safe variable name from a string [message #51032 is a reply to message #51029] Tue, 31 October 2006 10:15 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Ben Panter writes:

> I'm sure I've seen this here before, but extensive googling didn't
> trawl anything up. I'd like to be able to convert a random string into
> something I can use for a variable name (heavy execute'ing going on
> here). Something that clears out all the ./*/&//'s and the like. Ideally
> it would replace them with something useful, realistically I'd be happy
> if it just removed the unsafe characters from the string.
>
> something like:
>
> res=wonderful_routine('vmax_z0.1_0.3')
> print, res
> vmax_z0p1_0p3
>
> I've already written something similar which I can butcher, but I'm
> sure there was an IDL routine that did this already?

I think you must be talking about that wonderful (nee miraculous)
function Stregex. Combined with StrSplit and StrJoin, fabulous
things can be done in a single line!

http://www.dfanning.com/code_tips/stringsubs.html

Cheers,

David

P.S. Have you moved back to Edinburgh? Is your apartment
big enough for a visitor? :-)

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: xobjview creates phantom font object?
Next Topic: Re: Math Question

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

Current Time: Fri Oct 10 06:29:05 PDT 2025

Total time taken to generate the page: 0.16098 seconds