FieldCompareLeftExpression Property

Gets or sets the left part of the comparison expression.

Namespace:  Aspose.Words.Fields
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntax
public string LeftExpression { get; set; }

Property Value

Type: String
Examples
Shows how to insert a field that compares expressions.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Insert a compare field using a document builder
FieldCompare field = (FieldCompare)builder.InsertField(FieldType.FieldCompare, true);

// Construct a comparison statement
field.LeftExpression = "3";
field.ComparisonOperator = "<";
field.RightExpression = "2";

// The compare field will print a "0" or "1" depending on the truth of its statement
// The result of this statement is false, so a "0" will be show up in the document
Assert.AreEqual(" COMPARE  3 < 2", field.GetFieldCode());

builder.Writeln();

// Here a "1" will show up, because the statement is true
field = (FieldCompare)builder.InsertField(FieldType.FieldCompare, true);
field.LeftExpression = "5";
field.ComparisonOperator = "=";
field.RightExpression = "2 + 3";

Assert.AreEqual(" COMPARE  5 = \"2 + 3\"", field.GetFieldCode());

doc.UpdateFields();
doc.Save(ArtifactsDir + "Field.COMPARE.docx");
See Also