COMPARE Syntax error debugging assistance - Word 2002

R

rtrsr

I've had no problems creating and using simple { IF Expression1 Operator
Expression2 TrueText FalseText } merge codes but now I've plowed into a
stump.

This time, I want to test TWO conditions. Here's a diagram of what I'm
trying to do. I acknowledge it's not rocket science but I can't get it to
lift off the pad.

===============
IF
"{MERGEFIELD FileCustomField15}" = "FALSE"
***and***
{MERGEFIELD FileCustomField7} <> {MERGEFIELD FileCustomField7}

THEN

"[... text passage #1]"

ELSE

"[... text passage #2]"
================

I understand from the Help Screens that the way to do this is via the
COMPARE code. Well, it isn't working for me. It's probably a matter of not
putting "quotes" in the right place or otherwise not holding my mouth just
right when I type in the code, but after over two hours of beating on it, I
thought someone out here could give me a few pointers.

Here's what I've got (that doesn't work):


{IF {=AND ({COMPARE "{MERGEFIELD FileCustomField15}" = "FALSE"},
{COMPARE{MERGEFIELD FileCustomField7} <> {MERGEFIELD FileCustomField7} } ) }
= 1 "... text passage #1" "... text passage #2"}


I've followed the style in Word's Help Screen for the COMPARE code --
precisely I think. But I still get an "Error - Missing Test Condition."
I'm sure the error of my ways will be immediately obvious to one of you.
Can you help?

NOTE: {MERGEFIELD FileCustomField15} is a "string variable" while
{MERGEFIELD FileCustomField7} and MERGEFIELD FileCustomField7} are both
numerics.

Thanks!

Rick
 
P

Peter Jamieson

(Just noting that your second condition comapres something with itself)

YOu can use a nested IF. There's a limit to the number of levels and you
have to duplicate results. But e.g.

{ IF "{ MERGEFIELD FileCustomField15 }" = "FALSE"
"{ IF { MERGEFIELD FileCustomField7 } <> { MERGEFIELD FileCustomField7 }
"[... text passage #1]"
"[... text passage #2]" }" "[... text passage #2]" }

COMPARE returns 1 for a successful comparison, 0 otherwise. So you can AND
the results of two COMPAREs in an { = } field and test the result of that,
e.g.

{ IF { =and({ COMPARE "{ MERGEFIELD FileCustomField15 }" = "FALSE" },
{ COMPARE { MERGEFIELD FileCustomField7 } <> { MERGEFIELD
FileCustomField7 } }) } = 1
"[... text passage #1]"
"[... text passage #2]" }

You should be able to do more complicated and/or logic by nesting further
and(,) and or(,) functions.

Just make sure all the {} are the special field braces you can insert using
ctrl-F9
 
R

rtrsr

Ahhh. So THAT'S how you nest IF statements in this language! Once again,
Peter, your star burns ever brighter in the firmament!

Many, many thanks!!

Rick

PS > (Just noting that your second condition compares something with
itself) <
Uh, yeah... That's what happens when I try to type these commands in as
text. I got a little carried away with Word's Copy/Paste function. You're
quite right. A statement that "X <> X" might work in a Court of Law, but
not in any computer I've seen. So sorry for the confusion.


Peter Jamieson said:
(Just noting that your second condition comapres something with itself)

YOu can use a nested IF. There's a limit to the number of levels and you
have to duplicate results. But e.g.

{ IF "{ MERGEFIELD FileCustomField15 }" = "FALSE"
"{ IF { MERGEFIELD FileCustomField7 } <> { MERGEFIELD FileCustomField7 }
"[... text passage #1]"
"[... text passage #2]" }" "[... text passage #2]" }

COMPARE returns 1 for a successful comparison, 0 otherwise. So you can AND
the results of two COMPAREs in an { = } field and test the result of that,
e.g.

{ IF { =and({ COMPARE "{ MERGEFIELD FileCustomField15 }" = "FALSE" },
{ COMPARE { MERGEFIELD FileCustomField7 } <> { MERGEFIELD
FileCustomField7 } }) } = 1
"[... text passage #1]"
"[... text passage #2]" }

You should be able to do more complicated and/or logic by nesting further
and(,) and or(,) functions.

Just make sure all the {} are the special field braces you can insert using
ctrl-F9

--
Peter Jamieson - Word MVP
Word MVP web site http://word.mvps.org/

rtrsr said:
I've had no problems creating and using simple { IF Expression1 Operator
Expression2 TrueText FalseText } merge codes but now I've plowed into a
stump.

This time, I want to test TWO conditions. Here's a diagram of what I'm
trying to do. I acknowledge it's not rocket science but I can't get it to
lift off the pad.

===============
IF
"{MERGEFIELD FileCustomField15}" = "FALSE"
***and***
{MERGEFIELD FileCustomField7} <> {MERGEFIELD FileCustomField7}

THEN

"[... text passage #1]"

ELSE

"[... text passage #2]"
================

I understand from the Help Screens that the way to do this is via the
COMPARE code. Well, it isn't working for me. It's probably a matter of not
putting "quotes" in the right place or otherwise not holding my mouth just
right when I type in the code, but after over two hours of beating on
it,
I
thought someone out here could give me a few pointers.

Here's what I've got (that doesn't work):


{IF {=AND ({COMPARE "{MERGEFIELD FileCustomField15}" = "FALSE"},
{COMPARE{MERGEFIELD FileCustomField7} <> {MERGEFIELD FileCustomField7} } ) }
= 1 "... text passage #1" "... text passage #2"}


I've followed the style in Word's Help Screen for the COMPARE code --
precisely I think. But I still get an "Error - Missing Test Condition."
I'm sure the error of my ways will be immediately obvious to one of you.
Can you help?

NOTE: {MERGEFIELD FileCustomField15} is a "string variable" while
{MERGEFIELD FileCustomField7} and MERGEFIELD FileCustomField7} are both
numerics.

Thanks!

Rick
 

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