Jump to content

array error help


Recommended Posts

I keep getting this error from the JscrapeLib.au3

C:\Users\Rob&Tara\ftautosolid\JScrapeLib.au3 (600) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

If $scrapedchar_width = $Char_bank_width[$bankcount] AND $scrapedchar_height = $Char_bank_height[$bankcount] Then

If $scrapedchar_width = ^ ERROR

Here is the lie of code from that file:

Func Util_ScrapeText_ScrapeChar($topx, $topy, $bottomx, $bottomy)

    ; Scrape the character occupying the region bounded by the function arguments, but if it is bigger
    ; than the maximum size, ignore the excess pixels
    ; Then look for a match in the character bank, and if one is found, add the character to the scraped string

    Local $region_countx, $region_county, $char_countx, $char_county, $pixel
    Local $scrapedchar[$Char_maxheight + 1], $scrapedchar_width, $scrapedchar_height

    ; Scrape the char
    $region_county = $topy - 1 ; Count the region pixels from top to bottom
    $char_county = 0 ; Count the char pixels from top to bottom
    Do
        $region_county = $region_county + 1
        $char_county = $char_county + 1
        If $char_county <= $Char_maxheight Then
                $region_countx = $topx - 1 ; Count the region pixels from left to right
            $char_countx = 0 ; Count the char pixels from left to right
            Do
            $region_countx = $region_countx + 1
                $char_countx = $char_county + 1
                If $char_countx <= $Char_maxwidth Then
                    $pixel = PixelGetColor($region_countx, $region_county)
                    If $pixel = $Char_scrape_colour[1] Or $pixel = $Char_scrape_colour[2] Or $pixel = $Char_scrape_colour[3] Then
                        $scrapedchar[$char_county] = $scrapedchar[$char_county] & "x"
                    Else
                        $scrapedchar[$char_county] = $scrapedchar[$char_county] & " "
                    EndIf
                EndIf
            Until $region_countx = $bottomx
        EndIf
    Until $region_county = $bottomy

    ; Remember the height and width of the scraped character
    $scrapedchar_width = $region_countx - $topx + 1
    $scrapedchar_height = $region_county - $topy + 1

    ; Now look for a match in the character bank
    $bankcount = 0
    $bankmatch = 0
    Do
        $bankcount = $bankcount + 1
        ; Only compare characters of the right width and height
        If $scrapedchar_width = $Char_bank_width[$bankcount] AND $scrapedchar_height = $Char_bank_height[$bankcount] Then
            ; Compare each line in turn, and record any discrepancy
            $m = 0
            $c = 0
            Do
                $c = $c + 1
                If $Char_bank[$bankcount][$c] <> $scrapedchar[$c] Then
                    $m = $c
                EndIf
            Until $m > 0 OR $c = $scrapedchar_height

            If $m = 0 Then
                 ;The scraped char matches this charbank char
                $bankmatch = $bankcount
            EndIf
        EndIf
    Until $bankmatch > 0 OR $bankcount = $Char_bank_number

    ; If a match was found, add it to the scraped character array
    If $bankmatch > 0 Then

        ; If this is the first line, remember its position
        If $Char_scrape_lastlineposition = 0 Then
            $Char_scrape_lastlineposition = $Char_scrape_currentlineposition
        ; If the character is on a new line, add the delimiter "|" to the string
        ElseIf $Char_scrape_lastlineposition <> $Char_scrape_currentlineposition Then
            $Char_scrape_string = $Char_scrape_string & "|"
            $Char_scrape_lastlineposition = $Char_scrape_currentlineposition
        EndIf

        ; Add the character to the string, and remember how many characters have been scraped
        $Char_scrape_string = $Char_scrape_string & $Char_bank_chr[$bankmatch]
        $Char_scrape_count = $Char_scrape_count + 1

        Return "success"

    Else

        Return "fail"

    EndIf

EndFunc

Anyone know why this is happening?

Link to comment
Share on other sites

If don't know it will work or not, because I can't test it.

If $bankcount > (UBound($Char_bank_width) - 1) Then Exitloop
If $scrapedchar_width = $Char_bank_width[$bankcount] AND $scrapedchar_height = $Char_bank_height[$bankcount] Then
Link to comment
Share on other sites

If don't know it will work or not, because I can't test it.

If $bankcount > (UBound($Char_bank_width) - 1) Then Exitloop
If $scrapedchar_width = $Char_bank_width[$bankcount] AND $scrapedchar_height = $Char_bank_height[$bankcount] Then

can i send it to u?

this fixed the error but it seems to come up failing when searching for the text. Even though I know it's there.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...