Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word 97 Nested If Readability

Status
Not open for further replies.

jeffward

MIS
Jul 3, 2002
33
GB
I have a number of complicated mail merge documents and I have split these down into sub documents to improved readability from a coding/authoring point of view but some of them still contain a number of nested if statements and it is very hard read and maintain.

Is there any way of formating the nested if i.e. inserting blank lines that do not actually get printed?
 
One way to handle this is to code the IF statement so that the line(s) that might be blank are all coded on the one logical line and having the FALSE conditions output a carriage return or line-feed on an as needed basis eg:
{IF {MERGEFIELD Addr1}= "" "" "{MERGEFIELD Addr1}_"}{IF {MERGEFIELD Addr2}= "" "" "{MERGEFIELD Addr2}_"}{IF {MERGEFIELD Addr3}= "" "" "{MERGEFIELD Addr3}"}
where the underscore at the end of each FALSE result is your carriage return or line-feed. Note that there is no provision for a carriage return or line-feed at the end of the final FALSE result, since I've assumed that this field will be followed by a carriage return anyway.

Cheers
 
Thanks, but as some of the paragraphs are quite long and have nested conditions so a simple exmaple might be: -

{ IF {MERGEFIELD Test1} = "1"
"Text for option 1 goes here" ""
}
{ IF {MERGEFIELD Test1} = "2"
"Text for option 2 goes here" ""
}
{ IF {MERGEFIELD Test1} = "3
"Text for option 3 goes here" ""
} etc.

But the extra new lines that make this readable would be printed, is there any way to stop this ?
 
OK, if I understand you correctly, it's not the output that you want to have the carriage returns/line feeds in, but your fields (for readability purposes), without those extra carriage returns/line feeds showing up in the output.

That's something I've used extensively myself. For example, see:

The trick is to wrap the IF Statements inside a QUOTE field, thus:

{QUOTE
{ASK Test1 1}
{ASK Test2 2}
{ASK Test3 3}
{IF {Test1}= 1
"TRUE Text for option 1 goes here."
"FALSE Text for option 1 goes here."
}
{IF {Test2}= 2
"TRUE Text for option 2 goes here."
"FALSE Text for option 2 goes here."
}
{IF {Test3}= 3
"TRUE Text for option 2 goes here."
"FALSE Text for option 3 goes here."
}
}

The above carriage returns/line feeds aren't all required - they're just to show how extensively they can be used to format a field for readability once you start wrapping a QUOTE field around the lot. Any carriage returns/line feeds inside the quotes will still be reproduced in the final output.

When you start putting carriage returns/line feeds inside a QUOTE field this way, you might notice that the field dosn't always update properly if switching between the field code and its results until you scroll the field off-screen. A minor irritation, but it doesn't affect the output.

Cheers
 
Thanks macropod, that looks like exactly what i'm after, i will try it ASAP.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top