How to Force Verification if MORE THAN x checkmarks selected in OMR Group?

  • 73 Views
  • Last Post 2 weeks ago
jacob@imaging101.com posted this 27 August 2018

How to Force Verification if MORE THAN x checkmarks selected in OMR Group?

I have searched far and wide, but I still can’t figure out how to FORCE the Recognition if the user selects MORE than a specified number of Checkboxes in an OMR Group. 

In other words, for a particular OMR Checkmark Group, the group should be flagged for verification if the user selects MORE than THREE (3). 

I have a feeling this may have to be a Script.  But after searching Google, I still can’t find a decent example of how to do this. 

Thank you in advance!!!

 

Order By: Standard | Newest | Votes
Ekaterina posted this 19 September 2018

Hello,

Please use the “Result” parameter and ICheckMarkGroupValue collection to create the Custom recognition script. More details you may see here: Using scripts in ABBYY FlexiCapture > Scripts for customizing processing stages > Types of scripts > Custom recognition script

jacob@imaging101.com posted this 3 weeks ago

Hi Ekaterina,

Sorry it took me so long to reply.  It's been pretty crazy for us.  I created a C# Script as follows to handle this scenario.  In the future, it would be more helpful if you could include a quick code sample to show how exactly something like "ICheckMarkGroupValue" would be implemented.  I understand that for you, this is second hand and very easy.  But, for most of us who have not really worked within your Scripting engine, it is extremely confusing.  Here is the script;


//C#.NET EVEN BETTER Script to Check OMR Checkbox Groups

//Can use SPACE or Asterisk (*) to CLEAR Multiple Selections

//________________________________________________________

 

int numboxes = 0;

int numtotalcheckboxes = 7;

int numcheckboxesallowed = 3;

string groupname = "TRUSTEES";

string output = "";

 

for (int i = 1; i <= numtotalcheckboxes; i++)

{

    if (Context.Field(i.ToString()).Text != "")

    {

        numboxes++;

        output += ";" + Context.Field(i.ToString()).Text;

    }

}

if (Context.Field(groupname).Text == " " || Context.Field(groupname).Text.IndexOf("*") >= 0)

{

    Context.CheckSucceeded = true;

    Context.Field(groupname).Text = "* INVALIDATED - More Than " + numcheckboxesallowed.ToString() + " * ";

}

else if (numboxes > numcheckboxesallowed)

{

    Context.CheckSucceeded = false;

    Context.ErrorMessage = "More than three boxes checked for " + Context.Field(groupname).Name;

    Context.Field(groupname).Value = "";

}

else

{

    if (!string.IsNullOrEmpty(output))

    {

        Context.Field(groupname).Text = output.Substring(1);

    }

    else

    {

        Context.Field(groupname).Value = "";

    }

}

Ekaterina posted this 2 weeks ago

Thank you for this sample.

  • Liked by
  • jacob@imaging101.com
jacob@imaging101.com posted this 2 weeks ago

Here is an improved version that displays more informative error messages;


//C#.NET EVEN BETTER Script to Check OMR Checkbox Groups

//Can use SPACE or Asterisk (*) to CLEAR Multiple Selections

//________________________________________________________

 

//Initialize variables - DO NOT CHANGE

int numboxes = 0;

string output = "";

 

//Set Values for Current Field Group - CHANGE AS NEEDED

//NOTE: groupname is the "Alias Name" configured in Available Fields

int numtotalcheckboxes = 4;

int numcheckboxesallowed = 4;

string groupname = "TRUSTEES";

 

 

for (int i = 1; i <= numtotalcheckboxes; i++)

{

    if (Context.Field(i.ToString()).Text != "")

    {

        numboxes++;

        output += ";" + Context.Field(i.ToString()).Text;

    }

}

if (Context.Field(groupname).Text == " " || Context.Field(groupname).Text.IndexOf("*") >= 0)

{

    Context.CheckSucceeded = true;

    Context.Field(groupname).Text = "* INVALIDATED - More Than " + numcheckboxesallowed.ToString() + " * ";

}

else if (numboxes > numcheckboxesallowed)

{

    Context.CheckSucceeded = false;

    Context.ErrorMessage = "More than " + numcheckboxesallowed  + " boxes checked for " + Context.Field(groupname).Name;

    Context.Field(groupname).Value = "";

}

else

{

    if (!string.IsNullOrEmpty(output))

    {

        Context.Field(groupname).Text = output.Substring(1);

    }

    else

    {

        Context.Field(groupname).Value = "";

    }

}

Close