// область распознавания
$x1 = 600// верхний левый угол
$y1 = 470
$x2 = 670 // нижний правый
$y2 = 510
SUB(An, $let, $pict)
SCANPICTURE($ARR_SCAN, $x1,$y1, $x2,$y2, $pict, -1,100)
FOR($arr_num=0,$arr_num<ARRSIZE($ARR_SCAN),2)
ARRPUSH($ARR_OUT, $ARR_SCAN[$arr_num])
ARRPUSH($ARR_OUT, $let)
END_CYC
UNDEFINE($ARR_SCAN)
END_SUB
GETSCREEN
An("1","cifry\1.bmp")
An("2","cifry\2.bmp")
An("3","cifry\3.bmp")
An("4","cifry\4.bmp")
An("5","cifry\5.bmp")
An("+","cifry\+.bmp")
An("=","cifry\=.bmp")
$siz = ARRSIZE($ARR_OUT)
$srtcheck = 0
$srt = 0
FOR($a=$siz-2,($a>0)&($srt=0),-2)
FOR($b=0,$b<$a,2)
IF($ARR_OUT[$b] > $ARR_OUT[$b+2])
$srtcheck = 1
$tmp = $ARR_OUT[$b]
$tmp2 = $ARR_OUT[$b+1]
$ARR_OUT[$b] = $ARR_OUT[$b+2]
$ARR_OUT[$b+1] = $ARR_OUT[$b+3]
$ARR_OUT[$b+2] = $tmp
$ARR_OUT[$b+3] = $tmp2
END_IF
END_CYC
IF($srtcheck = 0)
$srt = 1
END_IF
END_CYC
$str = ""
FOR($a=0,$a<ARRSIZE($ARR_OUT),2)
IF(STRLEN($str) > 0)
$str = STRCONCAT($str, $ARR_OUT[$a+1])
ELSE
$str = $ARR_OUT[$a+1]
END_IF
END_CYC
UNDEFINE($ARR_OUT)
LOGWRITE ("Распознанная строка: ", $str) // в $str выводятся распознанные символы
IF((STRLEN($str) > 1)&((STRPOS($str, "+") > 0)|(STRPOS($str, "-") > 0)|(STRPOS($str, "*") > 0)|(STRPOS($str, "/") > 0)))
$str = STRFILTER($str, "1234567890-+*/", 1)
IF(STRPOS($str, "+") > 0)
STRSEPARATE($str, "+", $arr)
$str = $arr[0]+$arr[1]
UNDEFINE($arr)
ELSE
IF(STRPOS($str, "-") > 0)
STRSEPARATE($str, "-", $arr)
$str = $arr[0]-$arr[1]
UNDEFINE($arr)
ELSE
IF(STRPOS($str, "*") > 0)
STRSEPARATE($str, "*", $arr)
$str = $arr[0]*$arr[1]
UNDEFINE($arr)
ELSE
IF(STRPOS($str, "/") > 0)
STRSEPARATE($str, "/", $arr)
$str = $arr[0]/$arr[1]
UNDEFINE($arr)
END_IF
END_IF
END_IF
END_IF
END_IF
LOGWRITE ("Результат: ", $str)
LOGSHOW (1, 100,100)
HALT