From: webmasterATflymagnetic.com on
Hi,

anyone know how to escape double quotes in a format directive? I'm
trying to do the equivalent of the Unix shell command:

echo "<a href=\"$1\">$2</a>"

but with format:

(format t "<a href=~"~A~">~A</a>" text1 text2)

But CLISP says 'EVAL: variable ~A~ has no value.'

OK, so I guessed at the ~" being an escape of the double quote, mainly
on the fact that ~~ is an escape of the tilde. I guessed wrong. What's
the correct answer?

Phil
From: Morgan on
On Feb 6, 1:22 pm, "webmasterATflymagnetic.com"
<webmas...(a)flymagnetic.com> wrote:
> Hi,
>
> anyone know how to escape double quotes in a format directive? I'm
> trying to do the equivalent of the Unix shell command:
>
> echo "<a href=\"$1\">$2</a>"
>
> but with format:
>
> (format t "<a href=~"~A~">~A</a>" text1 text2)
>
> But CLISP says 'EVAL: variable ~A~ has no value.'
>
> OK, so I guessed at the ~" being an escape of the double quote, mainly
> on the fact that ~~ is an escape of the tilde. I guessed wrong. What's
> the correct answer?
>
> Phil

Hello Phil,

Use '\'.

(format t "string with a \" in it")

(format t "<a href=\"~A\">~A</a>" text1 text2)

hth
--Morgan
From: webmasterATflymagnetic.com on
On Feb 6, 6:34 pm, Morgan <bauer.mor...(a)gmail.com> wrote:
> On Feb 6, 1:22 pm, "webmasterATflymagnetic.com"
>
>
>
> <webmas...(a)flymagnetic.com> wrote:
> > Hi,
>
> > anyone know how to escape double quotes in a format directive? I'm
> > trying to do the equivalent of the Unix shell command:
>
> > echo "<a href=\"$1\">$2</a>"
>
> > but with format:
>
> > (format t "<a href=~"~A~">~A</a>" text1 text2)
>
> > But CLISP says 'EVAL: variable ~A~ has no value.'
>
> > OK, so I guessed at the ~" being an escape of the double quote, mainly
> > on the fact that ~~ is an escape of the tilde. I guessed wrong. What's
> > the correct answer?
>
> > Phil
>
> Hello Phil,
>
> Use '\'.
>
> (format t "string with a \" in it")
>
> (format t "<a href=\"~A\">~A</a>" text1 text2)
>
> hth
> --Morgan

he he, it works. Thanks!
From: Pascal J. Bourguignon on
"webmasterATflymagnetic.com" <webmaster(a)flymagnetic.com> writes:

> On Feb 6, 6:34�pm, Morgan <bauer.mor...(a)gmail.com> wrote:
>> On Feb 6, 1:22�pm, "webmasterATflymagnetic.com"
>>
>>
>>
>> <webmas...(a)flymagnetic.com> wrote:
>> > Hi,
>>
>> > anyone know how to escape double quotes in a format directive? I'm
>> > trying to do the equivalent of the Unix shell command:
>>
>> > echo "<a href=\"$1\">$2</a>"
>>
>> > but with format:
>>
>> > (format t "<a href=~"~A~">~A</a>" text1 text2)
>>
>> > But CLISP says 'EVAL: variable ~A~ has no value.'
>>
>> > OK, so I guessed at the ~" being an escape of the double quote, mainly
>> > on the fact that ~~ is an escape of the tilde. I guessed wrong. What's
>> > the correct answer?
>>
>> > Phil
>>
>> Hello Phil,
>>
>> Use '\'.
>>
>> (format t "string with a \" in it")
>>
>> (format t "<a href=\"~A\">~A</a>" text1 text2)
>>
>> hth
>> --Morgan
>
> he he, it works. Thanks!

I cannot understand why you guessed so.
Would you guess that in C, you'd escape double-quotes in strings with a
percent? printf("<a href=%"%s%">",url); ???

--
__Pascal Bourguignon__
From: webmasterATflymagnetic.com on
On Feb 7, 1:40 am, p...(a)informatimago.com (Pascal J. Bourguignon)
wrote:
> "webmasterATflymagnetic.com" <webmas...(a)flymagnetic.com> writes:
> > On Feb 6, 6:34 pm, Morgan <bauer.mor...(a)gmail.com> wrote:
> >> On Feb 6, 1:22 pm, "webmasterATflymagnetic.com"
>
> >> <webmas...(a)flymagnetic.com> wrote:
> >> > Hi,
>
> >> > anyone know how to escape double quotes in a format directive? I'm
> >> > trying to do the equivalent of the Unix shell command:
>
> >> > echo "<a href=\"$1\">$2</a>"
>
> >> > but with format:
>
> >> > (format t "<a href=~"~A~">~A</a>" text1 text2)
>
> >> > But CLISP says 'EVAL: variable ~A~ has no value.'
>
> >> > OK, so I guessed at the ~" being an escape of the double quote, mainly
> >> > on the fact that ~~ is an escape of the tilde. I guessed wrong. What's
> >> > the correct answer?
>
> >> > Phil
>
> >> Hello Phil,
>
> >> Use '\'.
>
> >> (format t "string with a \" in it")
>
> >> (format t "<a href=\"~A\">~A</a>" text1 text2)
>
> >> hth
> >> --Morgan
>
> > he he, it works. Thanks!
>
> I cannot understand why you guessed so.
> Would you guess that in C, you'd escape double-quotes in strings with a
> percent? printf("<a href=%"%s%">",url); ???
>
> --
> __Pascal Bourguignon__

I guessed on the understanding that format directives begin with a
tilde. In C all undefined \char resolve simply to char. Therefore
~" (equiv. \") resolves to ". Well That was my logic. :)

Phil