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

Home » Public Forums » archive » Re: Escaping Quotes
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: Escaping Quotes [message #44515] Tue, 21 June 2005 14:39
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
Michael Wallace wrote:
> ...I *knew* there was a simple way to
> escape a quote... just escape it with another quote...

Yeah, I *knew* that too. At least I used to know it, a long time ago in
a galaxy far, far away.

It's copied from Fortran, isn't it?


--
Mark Hadfield "Kei puwaha te tai nei, Hoea tahi tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
Re: Escaping Quotes [message #44529 is a reply to message #44515] Tue, 21 June 2005 10:54 Go to previous message
Michael Wallace is currently offline  Michael Wallace
Messages: 409
Registered: December 2003
Senior Member
> What about escape with quote ??
>
> print, '"This string doesn''t work ??"'
>

That was what I was forgetting. I *knew* there was a simple way to
escape a quote... just escape it with another quote. Thanks.

-Mike
Re: Escaping Quotes [message #44534 is a reply to message #44529] Mon, 20 June 2005 23:53 Go to previous message
Antonio Santiago is currently offline  Antonio Santiago
Messages: 201
Registered: February 2004
Senior Member
Michael Wallace wrote:

> I am having a brain cramp right now and can't even remember the simplest
> of IDL. How do you escape quotes given that you want both single and
> double quotes to appear in the string?
>
> '"This string doesn't work"'
>
> Naturally, I tried using the standard slash-style escaping you find in
> other languages, but to no avail.
>
> -Mike

What about escape with quote ??

print, '"This string doesn''t work ??"'

bye ;)
--
-----------------------------------------------------
Antonio Santiago P�rez
( email: santiago<<at>>grahi.upc.edu )
( www: http://www.grahi.upc.edu/santiago )
( www: http://asantiago.blogsite.org )
-----------------------------------------------------
GRAHI - Grup de Recerca Aplicada en Hidrometeorologia
Universitat Polit�cnica de Catalunya
-----------------------------------------------------
Re: Escaping Quotes [message #44537 is a reply to message #44534] Mon, 20 June 2005 17:35 Go to previous message
Peter Mason is currently offline  Peter Mason
Messages: 145
Registered: June 1996
Senior Member
Michael Wallace wrote:
> I am having a brain cramp right now and can't even remember the
> simplest of IDL. How do you escape quotes given that you want both
> single and double quotes to appear in the string?
>
> '"This string doesn't work"'
>
> Naturally, I tried using the standard slash-style escaping you find in
> other languages, but to no avail.

Although I feel safer with Mark's approach myself, there's also:
s = "What's ""leveraged""?"
and
s = 'What''s "leveraged"?'

(I hope you're viewing this with a fixed-space font.)
Re: Escaping Quotes [message #44538 is a reply to message #44537] Mon, 20 June 2005 16:55 Go to previous message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
Michael Wallace wrote:
> I am having a brain cramp right now and can't even remember the simplest
> of IDL. How do you escape quotes given that you want both single and
> double quotes to appear in the string?
>
> '"This string doesn't work"'
>
> Naturally, I tried using the standard slash-style escaping you find in
> other languages, but to no avail.

Doubtless there are many different ways to do it, using formatted
strings or byte<->string conversion or what-have-you, but the way that
seems simplest to my limited brain is to break the problem down into
substrings then recombine them:

IDL> print, '"This string mightn'+"'"+'t work, but it does!"'
"This string mightn't work, but it does!"


Ugly, though.

--
Mark Hadfield "Kei puwaha te tai nei, Hoea tahi tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: How to calculate the curve area?
Next Topic: converting bytarr into strarr

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

Current Time: Wed Oct 08 13:53:28 PDT 2025

Total time taken to generate the page: 0.00605 seconds