Script in FlexiCapture

  • 352 Views
  • Last Post 26 September 2018
Stephen posted this 21 August 2018

Hi All,

 

I am new to this software and I know a bit about VBA.

 

I am going to create some script in FlexiCapture but one of my headache is dont know how to understand all possible properties/method that Abbyy have.

 

For example,


Dim ItemsCount, count2

dim Sum, i

 

Sum = 0

ItemsCount = me.Field("Pts_1").Items.Count

 

If Not ( me.Field("TotalPoints").Items Is Nothing ) Then

    count2 = me.Field("TotalPoints").Items.Count

End if

 

for i = 0 to ItemsCount - 1

    Sum = Sum + me.Field("Pts_1").Items.Item(i).Value

Next

dim sumStr, s


How can i know Me.Field("fieldname") have .Items.item(i).Value method?

 

If i search "Me.Field" in F1, it doesnt looks smart, any suggestion on this?

 

Thanks

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

Hello,

We cannot tell for sure, without seeing your FC project, but it looks like you have in the rule two table's or repeating group's fields with aliases. 

In this case the rule should be placed on the level higher that the table/repeating group (e.g. on the level of the section).

Then you'll get access to the table cells via the Field corresponding to the table cell (let's name it Field("Table_Cell"), not to the field corresponding to the entire table. 

It would be something like (we use C# syntax, but you may transfer the same to the VBA): 

for (int row_index = 0; row_index < Context.Field("Table_Cell").Count; row_index++) 

string tableCellText = Context.Field("Table_Cell").Items[row_index].Text; 

//other part of rule script here 

If you want to treat the value as a number, you should somehow cast the IValue Context.Field("Table_Cell").Items[row_index].Value property to a number type, before applying any number operations.

To debug the the script in the FlexiCapture you also may use the FCTools.ShowMessage() method.

To give you more accurate advice, we would like to take a look on your project and we need to know your intended scenario.

Stephen posted this 12 September 2018

Thanks Ekaterin for answering.

Can I understand "string tableCellText = Context.Field("TableA").Items[0].Text; " refers to the first record of TableA ?

 

What I doubt is wonder if the meaning of "me.Field("TableA").Items.Item(i).Value" in VB.

Is it the same as "Context.Field("TableA").Items[].Value;" in C# ?

 

Looking forward to your advice.

 

Ekaterina posted this 26 September 2018

Hello,

You should refer to the columns of your table, not to the rows or another instances. Please see the sample on the VB:

Dim ItemsCount, row_index

ItemsCount = Me.Field("Column2").Items.Count

for row_index = 0 to ItemsCount - 1

    Me.Field("Field").Text = // string to display

Next

Close