Using double quotes in IF results

J

Joey

Does anyone know how to include double quotes in the results of an IF
express, as in:

{ IF TextString = "anytext" "This is the "true" result" "This is the "false"
result" }

Any help is greatly appreciated.
 
G

Greg

Use a nested {Symbol 034} field in each place you want the quote symbol
to appear. E.g.,


"....{Symbol 034}true{Symbol 034}..."
 
S

Suzanne S. Barnhill

034 will give you straight quotes. If you want the curly ones, you'll need
to use 147 (left) and 148 (right). Alternatively, you can use two single
quotes.
 
J

Joey

Thanks to both of you for your responses. Unfortunately, this doesn't always
work. Specifically, it's failing for me if the {symbo} field is the first or
last thing in the result text. Try this:
{ IF "a"="b" "{Symbol 034}text1{Symbol 034}" "{Symbol 034}text2{Symbol 034}" }
Yields: text2

Now try this:
{ IF "a"="b" "my{Symbol 034}true{Symbol 034}text" "my{Symbol
034}false{Symbol 034}text" }
Yields: my"false"text

I can only speculate why Word is dropping the quotes in the first example.
Is this a bug or is there some nuance of this feature that is eluding me? If
all else fails I can continue to use two single quotes.

Again, any help you can provide is greatly appreciated.
 
G

Greg Maxey

Joey,

Odd. Replace { Symbol 034 } with { Quote 34 }. That is working here with
your example.
 
G

Greg Maxey

Or even cleaner with your example:

{ IF "a"="b"{ Quote 34 text1 34 }{ Quote 34 text2 34}}
 
G

Greg Maxey

Joey,

Here is an example when the quoted text is first, last, or in the middle.

{ IF "a"="a"{ Quote 34 True 34 }{ Quote "This is a " 34 false 34 "
statement" }}
 
G

Graham Mayor

And if all else fails save the texts as autotext entries and insert autotext
fields in the conditional statement to place them.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
B

Bob S

Does anyone know how to include double quotes in the results of an IF
express, as in:

{ IF TextString = "anytext" "This is the "true" result" "This is the "false"
result" }

Any help is greatly appreciated.

Below are a few methods.

Note that it comes out somewhat hard to read in the newsgroup because
both the straight and curly quotes look the same. You will need to use
a bit of imagination to get the picture. The idea is that the quote
marks around the target quotation are supposed to be curly, and the
quote marks that separate portions of the field codes are supposed to
be straight.

Bob S


Quoted Text in IF Fields

Trying to put text that contains embedded quotation marks into the
true or false text of IF field codes can be "interesting". There are a
couple ways to do it. As an example, suppose that you want the output
of an IF field to look like this:

Say "cheese!"

One scheme is to use the QUOTE field to produce the correct quotes.
For example:

{ IF Something "Say { QUOTE "\"" }cheese!{ QUOTE "\"" }" "No!" }

It is inordinately difficult to get this to work. The only way that I
could get the QUOTE fields correct was to use CTRL+F9 to get the
brackets and type directly. Using the Insert | Field dialog produced
straight quotes not curly quotes. Also note that to get the opening
quotes in the first QUOTE field, I typed "\ "" and then deleted the
space character.

Another alternative is to use a pair of single quote characters to
make something that looks somewhat like double quotes:

{ IF Something "Say ''cheese!''" "No!" }

Again, it is unreasonably difficult to get this to work. I had to use
CTRL+F9 to get the brackets (instead of Insert | Field), then type
QUOTE instead of IF (If I used IF I would get straight quotes when I
typed the rest of the text!) and type in the rest of the field, and
then go back and change the QUOTE to IF. Also, to get the two single
opening quotes I had to start with a space between them and then
delete the space.

While you are trying these things, remember to update field codes
every time that you change something.

My favorite scheme at the moment is to first type the correct text,
type QUOTE in front of it, put backslashes in front of the internal
quote characters, add the straight quote characters needed by the
QUOTE field, use CTRL+F9 to put field brackets around it, type in the
rest of the IF field stuff, and then select the whole field code and
use CTRL+F9 to put field brackets around that. It all has to be done
in order.

The process is:

Say "cheese!"
QUOTE Say "cheese!"
QUOTE Say \"cheese!\"
QUOTE "Say \"cheese!\""
{ QUOTE "Say \"cheese!\""}
{ IF Something { QUOTE "Say \"cheese!\""} "No!" }


A different approach was suggested by "macropod". Use the ASCII
numbers for the quote characters, inside QUOTE fields.

{ IF Something "Say { QUOTE 34 }cheese!{ QUOTE 34 }" "No!" }

34 straight double quote
147 left curly double quote
148 right curly double quote
39 straight single quote
145 left curly single quote
146 right curly single quote
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top