Thank you for this great OCR Reader. I wrote a recheck OCR file funtion. With this function you can recheck all entries in your OCR File again.
This is my code:
#include "OCR.au3" ;or add the code below directly into OCR.au3
#include <Array.au3>
#include <File.au3>
; Start code by autoscript.com user Beonn, function _CheckOCRFile
Func _CheckOCRFile($fontFile="")
If $fontFile = "" Then $fontFile = @ScriptDir & "\OCRFontData.txt"
Local $fileOld = FileOpen($fontFile, 0)
Local $fileNew = FileOpen($fontFile & ".tmp", 2)
; Check if file opened for reading OK
If $fileOld = -1 Then
MsgBox(0, "Error", "Unable to open data file.")
Exit
EndIf
$_startdb = 0
For $i = 1 To _FileCountLines($fontFile)
Local $line = FileReadLine($fileOld, $i)
Select
Case @error = -1
ExitLoop
Case Not $_startdb
If StringInStr($line,@TAB & "-99") Then $_startdb = 1
FileWriteLine($fileNew, $line)
Case Not StringInStr($line,"err" & @TAB & "!") And $_startdb
$_dbreturn = StringSplit($line, @TAB)
If IsArray($_dbreturn) Then
$letter = $_dbreturn[1]
$saveWindowForFont = $_dbreturn[3]
EndIf
$_dbreturn = StringSplit($_dbreturn[2], "|")
;_ArrayDisplay($_dbreturn, "DB return", Default, 8)
If IsArray($_dbreturn) Then
$image = ""
$_len = 0
For $j = 1 To UBound($_dbreturn) - 1
$_lentemp = StringLen(_NumberToBinary(Abs(Number($_dbreturn[$j]))))
If $_lentemp > $_len Then $_len = $_lentemp
Next
For $j = 1 To $_len
For $k = 1 To UBound($_dbreturn) - 1
If StringMid(StringReverse(_NumberToBinary(Abs(Number($_dbreturn[$k])))), $j, 1) = 1 Then
$image = $image & "#"
Else
$image = $image & "~"
EndIf
Next
$image = $image & @CRLF
Next
Else
ContinueLoop
EndIf
; Now calculate the required size of the msgbox to display the pattern
$boxWidth = UBound($_dbreturn) * 8 + 40
If $boxWidth < 200 Then $boxWidth = 200
If $boxWidth > @DesktopWidth Then $boxWidth = @DesktopWidth
$boxHeight = $_len * 13 + 120
If $boxHeight < 500 Then $boxHeight = 500
If $boxHeight > @DesktopHeight Then $boxHeight = @DesktopHeight
; And display it
$userResponse = InputBox("Control Character", "Please identify this pattern" & @CR & "(Empty string or Cancel will delete this from Fontfile):-" & @CR & @CR & $image, $letter, "", $boxWidth, $boxHeight, @DesktopWidth - $boxWidth, @DesktopHeight - $boxHeight - 50) ;-50 for Windows Taskbar
If Not @error = 1 And $userResponse <> "" Then
If $letter = $userResponse Then
; User didn't change anything
FileWriteLine($fileNew, $line)
Else
;The data was incorrect
$letter = $userResponse
$pattern = _ArrayToString($_dbreturn, "|", 1)
FileWriteLine($fileNew, $letter & $pattern & $saveWindowForFont & @CRLF)
EndIf
EndIf
Case Else
FileWriteLine($fileNew, $line)
EndSelect
Next
FileClose($fileOld)
FileClose($fileNew)
; Now replace old file with new
FileMove ( $fontFile & ".tmp", $fontFile, 1 )
cleanFontDataFile($fontFile)
EndFunc
; End code by autoscript.com user Beonn, function _CheckOCRFile
; Start code added by autoscript.com user Beonn, function _NumberToBinary from https://www.autoitscript.com/forum/topic/90056-decimal-to-binary-number-converter/
; =================================================================================================
; Func _NumberToBinary($iNumber)
;
; Converts a 32-bit signed # to a binary bit string. (Limitation due to AutoIT functionality)
; NOTE: range for 32-bit signed values is -2147483648 to 2147483647!
; Anything outside the range will return an empty string!
;
; $iNumber = # to convert, obviously
;
; Returns:
; Success: Binary bit string
; Failure: "" and @error set
;
; Author: Ascend4nt, with help from picaxe (Changing 'If BitAND/Else' to just one line)
; See it @ http://www.autoitscript.com/forum/index.php?showtopic=90056
; =================================================================================================
Func _NumberToBinary($iNumber)
Local $sBinString = ""
; Maximum 32-bit # range is -2147483648 to 2147483647
If $iNumber<-2147483648 Or $iNumber>2147483647 Then Return SetError(1,0,"")
; Convert to a 32-bit unsigned integer. We can't work on signed #'s
$iUnsignedNumber=BitAND($iNumber,0x7FFFFFFF)
; Cycle through each bit, shifting to the right until 0
Do
$sBinString = BitAND($iUnsignedNumber, 1) & $sBinString
$iUnsignedNumber = BitShift($iUnsignedNumber, 1)
Until Not $iUnsignedNumber
; Was it a negative #? Put the sign bit on top, and pad the bits that aren't set
If $iNumber<0 Then Return '1' & StringRight("000000000000000000000000000000" & $sBinString,31)
Return $sBinString
EndFunc ;==>_NumberToBinary
; End code added by autoscript.com user Beonn, function _NumberToBinary