Question
How to declare a local function in C# script in FineReader Server 14?
Answer
With C#, you can declare local functions only using lambda expressions. Please see the following ABBYY Online Help topic for more details: https://help.abbyy.com/en-us/finereaderserver/14/help/scriptlocal/
The following example script is using the lambda expression to declare a local function setAttribute:
using System;
using System.IO;
bool setAttrComplete = false;
System.Func<string, string, bool>setAttribute = (attrName, attrValue) => {
for( int i = 0; i < doc.Attributes.Count; i++ ) {
var attribute = doc.Attributes[i];
if( attribute.Name == "Product Name" ) {
attribute.Value = "newValue";
break;
}
}
return true;
};
setAttrComplete = setAttribute("attName", "attValue");
More details about lambda expressions in C# can be found in Microsoft documentation: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/lambda-expressions
Comments
0 comments
Please sign in to leave a comment.