Replace Quotes with Escaped Quotes in String

Brahmanathaswami brahma at hindu.org
Sun Dec 13 15:01:23 EST 2015


I'm trying out doing all dev now in 8 dp*  since I have no immediate 
production projects that require deployment. So far so good, though I 
miss BV2 documentation... (which seems to hang the app if I leave it in 
my plug-ins folder)  and LCBrowser (also seems to be troublesome.)

I'm trying to pass text to a variable with the quotes escaped so that 
they will be retained in a shell call to mail using echo, actually this 
is inside a linux 7.0.1 LC server cgi script:

put dayInfo() into tVisitorsInfo

     if tVisitorsInfo is empty then exit to top

       put getAddresses() into tAddresses
       put tVisitorsInfo into tBody
       replace quote with ( "\" & quote)  ) in tBody
       # above does not work, quotes are stripped out
       # also does not break anything
       put ("echo " & quote & tBody & quote & " | ") into tCmd
       put format ("mail -s \"Visitor Care Notice\" -r 
\"No-Reply at hindu.org\" " & tAddresses) after tCmd
       get shell(tCmd)

it doesn't work... the quotes are just removed in the output (email body)

Thinking this may be some linux shell text processing issue, I tried 
this on my desk top:

1) make new stack
2) create two fields: i. "input ii. "output"
3) enter text with quotes in input field

Kevin Miller says, "Great things are coming!"  and we actually see them 
popping up in LC 8.. Hurray!

3) button:
on mouseUp
put fld "input" into jai
replace quote with ( "\" & quote) in jai
put jai into fld "output"
end mouseUp

4) result in fld "output"

Kevin Miller says, "Great things are coming!"  and we actually see them 
popping up in LC 8.. Hurray!

at least the quotes are not stripped... (as they are in the attempt to 
pass to echo)

So, I'm flummoxed... docs use, as an example:

replace return....

using the constant  "return"

so one would expect using the constant  "quote" to be targetable

I also tried format... but it also fails silently i.e. no replacement 
and no error

on mouseUp
put fld "input" into jai
put format ("\\ & \"") into tEscapedQuote
replace quote with tEscapedQuote in jai
put jai into fld "output"
end mouseUp

BR




More information about the use-livecode mailing list