Understanding and Implementing Functions in FlexiCapture 12 Scripts

Question

How can one define and utilize a function within a script in FlexiCapture 12?

Answer

In FlexiCapture 12, defining and using functions within scripts enhances the flexibility and efficiency of document processing. As an example, consider the following function designed to calculate the average confidence of the entire word:

using System; 

//declaration
Func<IField, double> calculateAverage = f =>
{
if (f.Symbols == null || f.Symbols.Count == 0) return 0;
int sum = 0;
for (var i=0;i<f.Symbols.Count;i++)
sum += f.Symbols[i].Confidence;

int count = f.Symbols.Count;
return sum / count;
};

//demonstration
FCTools.ShowMessage(calculateAverage(Context).ToString());

This function, named calculateAverage, takes an IField object as input, representing a word in the document. It then calculates the average confidence of the individual symbols within that word. Utilizing such functions streamlines code, making it more readable and maintainable, ultimately enhancing the overall processing capabilities of FlexiCapture 12 scripts.

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.