Don't know how to use properly the instr instruction

Don't know how to use properly the instr instruction

Postby mirodonie.george » Mon Nov 19, 2012 1:27 am

Hello Guys,

I'm having a little trouble with My SBL script. All I want is to give me an error when the operator try to go to the next document with some errors inside the index fields.

Here is an example: if we need 123456 and we have 123456'' or some random character such "`,@,%,^,#, ".

I whrote some code for this but I think i'm missing something:


Code: Select all
Function KfxDocPostProcess ( Id As Long, DataAccepted As Integer) As Integer
   On Error GoTo Failure

   Dim Operation As String                ' example code
   If (DataAccepted = 1) Then             ' example code
      Operation = "Requested Save Index Data" ' example code
   Else                             ' example code
      Operation = "Cancelled Save Index Data" ' example code
   End If                              ' example code


   KfxDocPostProcess = NoError
   Exit Function

Failure:
   KfxDocPostProcess = FatalError
   if instr(KfxId," ") > 0 Then
   
 
   KfxDocPostProcess = FatalError
   
Else
KfxDocPostProcess = NoError
   End If
   Exit Function
End Function
mirodonie.george
Participant
 
Posts: 9
Joined: Tue Mar 27, 2012 1:10 am

Re: Don't know how to use properly the instr instruction

Postby DavidCrewe » Mon Nov 19, 2012 2:43 am

Hi,

You seem to be using the Instr inside the error handler, but there is no code to send the processing to that error handler.

Normally you would use the Instr check inside the main function and then set the error status depending on the test.

Also, you could use PreDocProcess or fieldPost events for this sort of checking. Often this is neater as it will keep the focus on the field with an error.

If you need some more advice, feel free to e-mail me with some more detail on exactly what you are trying to check, and what the document process looks like...

David
David Crewe

Check out our set of custom add-ons for Kofax Capture - www.DavidCrewe.com/products.html
DavidCrewe
Participant
 
Posts: 232
Joined: Tue Apr 29, 2008 2:24 am
Location: UK

Re: Don't know how to use properly the instr instruction

Postby russell@centuryc.com » Mon Nov 19, 2012 12:13 pm

I see two problems. First, you're trying to detect this within the post processing for the Document. Sadly, the only choices you have at that point is: Accept the document, Reject the document (and send the whole batch to QC), or Reject the document (but continue on Validating the rest of the batch before going to QC). Making the operator go back to the document simply isn't an option at that time.

But you've also but your test in the wrong location. Note that SBL is a procedural language, not a object language. You can't define a document has having an error by putting a check in the error handler.

As pointed out, the best place to put this test is somewhere else. Perhaps the DocPreProcess (to decided if you can SaveAndSkip or if operator intervention is needed), or the Field PreProcess (same thing at the field level) or most likely in the Field PostProcess, (the only place you can tell the operator - "No, you have to fix this. You're not going anywhere until you do.")

Using the DocumentPostProcess is more like the "nuclear option" option to catch problems that might otherwise slip though. It has it's place, but it's not your first line of defense.
Russell
russell@centuryc.com
Participant
 
Posts: 3374
Joined: Wed May 17, 2006 12:53 pm
Location: USA

Re: Don't know how to use properly the instr instruction

Postby russell@centuryc.com » Mon Nov 19, 2012 12:13 pm

I see two problems. First, you're trying to detect this within the post processing for the Document. Sadly, the only choices you have at that point is: Accept the document, Reject the document (and send the whole batch to QC), or Reject the document (but continue on Validating the rest of the batch before going to QC). Making the operator go back to the document simply isn't an option at that time.

But you've also but your test in the wrong location. Note that SBL is a procedural language, not a object language. You can't define a document has having an error by putting a check in the error handler.

As pointed out, the best place to put this test is somewhere else. Perhaps the DocPreProcess (to decided if you can SaveAndSkip or if operator intervention is needed), or the Field PreProcess (same thing at the field level) or most likely in the Field PostProcess, (the only place you can tell the operator - "No, you have to fix this. You're not going anywhere until you do.")

Using the DocumentPostProcess is more like the "nuclear option" option to catch problems that might otherwise slip though. It has it's place, but it's not your first line of defense.
Russell
russell@centuryc.com
Participant
 
Posts: 3374
Joined: Wed May 17, 2006 12:53 pm
Location: USA

Re: Don't know how to use properly the instr instruction

Postby aadslingerland » Tue Nov 20, 2012 12:16 am

Gents,

I think this SBL function can help filtering out all kind off rubbish... Have a look...

Code: Select all
function FilterString (source as string) as string
'
' Filter a set of characters out of the source string and return the result.
' The characters filtered are:
' chr (34)  double quote
' chr (39)  single quote
' chr (44)  comma
' chr (46)  dot
' etc...
'
   dim index as integer                ' index in source
   dim one_char as string              ' one isolated char from source
   dim filter as string                ' filter these characters
   dim result as string                ' build result here
   '
   result = ""
   filter = "[" & chr$ (34) & Chr$ (39) & "~`!@#$%^&*(){}|;:<>,.?]"
   '
   for index = 1 to len (source)
      one_char = mid$ (source, index, 1)
      if one_char like filter = false then
         result = result & one_char
      end if
   next
   FilterString = result
end function
With Regards, Aad Slingerland
User avatar
aadslingerland
Participant
 
Posts: 299
Joined: Tue Sep 22, 2009 12:23 am


Return to Release Scripts General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest