1<?xml version="1.0" encoding="UTF-8"?> 2 3<!--*********************************************************** 4 * 5 * Licensed to the Apache Software Foundation (ASF) under one 6 * or more contributor license agreements. See the NOTICE file 7 * distributed with this work for additional information 8 * regarding copyright ownership. The ASF licenses this file 9 * to you under the Apache License, Version 2.0 (the 10 * "License"); you may not use this file except in compliance 11 * with the License. You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, 16 * software distributed under the License is distributed on an 17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 18 * KIND, either express or implied. See the License for the 19 * specific language governing permissions and limitations 20 * under the License. 21 * 22 ***********************************************************--> 23 24<helpdocument version="1.0"> 25<meta> 26<topic id="textswriterguideconditional_textxml" indexer="include" status="PUBLISH"> 27<title xml-lang="en-US" id="tit">Conditional Text</title> 28<filename>/text/swriter/guide/conditional_text.xhp</filename> 29</topic> 30</meta> 31<body> 32<bookmark xml-lang="en-US" branch="index" id="bm_id3155619"> 33<bookmark_value>matching conditional text in fields</bookmark_value> 34<bookmark_value>if-then queries as fields</bookmark_value> 35<bookmark_value>conditional text; setting up</bookmark_value> 36<bookmark_value>text; conditional text</bookmark_value> 37<bookmark_value>defining;conditions</bookmark_value> 38</bookmark> 39<paragraph xml-lang="en-US" id="hd_id3155619" role="heading" level="1" l10n="U"><variable id="conditional_text"><link href="text/swriter/guide/conditional_text.xhp" name="Conditional Text">Conditional Text</link> 40</variable></paragraph> 41<paragraph xml-lang="en-US" id="par_id3155879" role="paragraph" l10n="U">You can set up fields in your document that display text when a condition that you define is met. For example, you can define the conditional text that is displayed in a series of reminder letters.</paragraph> 42<paragraph xml-lang="en-US" id="par_id3155895" role="paragraph" l10n="U">Setting up conditional text in this example is a two-part process. First you create a variable, and then you create the condition.</paragraph> 43<paragraph xml-lang="en-US" id="hd_id3153175" role="heading" level="2" l10n="U">To Define a Conditional Variable</paragraph> 44<paragraph xml-lang="en-US" id="par_id3153185" role="paragraph" l10n="U">The first part of the example is to define a variable for the condition statement.</paragraph> 45<list type="ordered"> 46<listitem> 47<paragraph xml-lang="en-US" id="par_id3155566" role="listitem" l10n="U">Choose <item type="menuitem">Insert - Fields - Other</item>, and then click the <item type="menuitem">Variables</item> tab.</paragraph> 48</listitem> 49<listitem> 50<paragraph xml-lang="en-US" id="par_id3147759" role="listitem" l10n="U">Click "Set variable" in the <item type="menuitem">Type</item> list.</paragraph> 51</listitem> 52<listitem> 53<paragraph xml-lang="en-US" id="par_id3147784" role="listitem" l10n="U">Type a name for the variable in the <item type="menuitem">Name</item> box, for example <item type="literal">Reminder</item>.</paragraph> 54</listitem> 55<listitem> 56<paragraph xml-lang="en-US" id="par_id3147810" role="listitem" l10n="U">Click "Text" in the <item type="menuitem">Format</item> list.</paragraph> 57</listitem> 58<listitem> 59<paragraph xml-lang="en-US" id="par_id7748344" role="listitem" l10n="NEW">Enter <item type="literal">1</item> in the <item type="menuitem">Value</item> box, and then click <item type="menuitem">Insert</item>.<br/>The Format list now displays a "General" format.</paragraph> 60</listitem> 61</list> 62<paragraph xml-lang="en-US" id="hd_id3145645" role="heading" level="2" l10n="U">To Define a Condition and the Conditional Text</paragraph> 63<paragraph xml-lang="en-US" id="par_id3145659" role="paragraph" l10n="U">The second part of the example is to define the condition that must be met, and to insert a placeholder for displaying the conditional text in your document.</paragraph> 64<list type="ordered"> 65<listitem> 66<paragraph xml-lang="en-US" id="par_id3151193" role="listitem" l10n="U">Place the cursor where you want to insert the conditional text in your text.</paragraph> 67</listitem> 68<listitem> 69<paragraph xml-lang="en-US" id="par_id3151212" role="listitem" l10n="U">Choose <item type="menuitem">Insert - Fields - Other</item>, and then click the <item type="menuitem">Functions</item> tab.</paragraph> 70</listitem> 71<listitem> 72<paragraph xml-lang="en-US" id="par_id3151250" role="listitem" l10n="U">Click "Conditional text" in the <item type="menuitem">Type</item> list.</paragraph> 73</listitem> 74<listitem> 75<paragraph xml-lang="en-US" id="par_id3155936" role="listitem" l10n="U">Type <item type="literal">Reminder EQ "3"</item> in the <item type="menuitem">Condition</item> box. In other words, the conditional text will be displayed when the variable in the field that you defined in the first part of this example is equal to three.</paragraph> 76<paragraph xml-lang="en-US" id="par_id3155969" role="listitem" l10n="U">The quotation marks enclosing the "3" indicate that the variable that you defined in the first part of this example is a text string.</paragraph> 77</listitem> 78</list> 79<list type="ordered" startwith="5"> 80<listitem> 81<paragraph xml-lang="en-US" id="par_id3150446" role="listitem" l10n="U">Type the text that you want to display when the condition is met in the <emph>Then</emph> box. There is almost no limit to the length of the text that you can enter. You can paste a paragraph into this box.</paragraph> 82</listitem> 83<listitem> 84<paragraph xml-lang="en-US" id="par_id3150473" role="listitem" l10n="U">Click <emph>Insert</emph>, and then click <emph>Close</emph>.</paragraph> 85</listitem> 86</list> 87<paragraph xml-lang="en-US" id="hd_id3155073" role="heading" level="2" l10n="U">To Display the Conditional Text</paragraph> 88<paragraph xml-lang="en-US" id="par_id3155086" role="paragraph" l10n="U">In this example, the conditional text is displayed when the value of the conditional variable is equal to 3.</paragraph> 89<list type="ordered"> 90<listitem> 91<paragraph xml-lang="en-US" id="par_id3155110" role="listitem" l10n="U">Place your cursor in front of the field that you defined in the first part of this example, and then choose <emph>Edit - Fields</emph>.</paragraph> 92</listitem> 93<listitem> 94<paragraph xml-lang="en-US" id="par_id3155136" role="listitem" l10n="U">Replace the number in the <item type="menuitem">Value</item> box with 3, and then click <item type="menuitem">Close</item>.</paragraph> 95</listitem> 96<listitem> 97<paragraph xml-lang="en-US" id="par_id3155168" role="listitem" l10n="U">If the field does not automatically update, press F9.</paragraph> 98</listitem> 99</list> 100<section id="relatedtopics"> 101<embed href="text/swriter/guide/fields_userdata.xhp#fields_userdata"/> 102<embed href="text/swriter/guide/conditional_text2.xhp#conditional_text2"/> 103<embed href="text/swriter/01/04090200.xhp#defining_conditions"/> 104<paragraph xml-lang="en-US" id="par_id3145714" role="paragraph" l10n="C"><link href="text/swriter/02/14020000.xhp" name="List of conditional operators">List of conditional operators</link></paragraph> 105</section> 106</body> 107</helpdocument> 108