Type Mismatch.

I’m slightly confused… I’m well into making a channel, and when I added some code, I get a type mismatch error.

Here’s my Initialization:


    Dim Xn[9, 9]
    Dim Yn[9, 9]
    for y = 1 to 9
        for x = 1 to 9
            Orig[x, y] = Int(Val(Mid(OrigStr,z,1)))
            if(Orig[x, y] > 0) then
                Xn[x, Orig[x, y]] = 1
                Yn[y, Orig[x, y]] = 1
            else
                Xn[x, Orig[x, y]] = 0
                Yn[y, Orig[x, y]] = 0
            end if
...

That all seems to work perfect. However when I try to increment a position, it crashes with a type mismatch error on line:


Xn[mx, Play[mx, my]] = Xn[mx, Play[mx, my]] + 1

And yet this line works flawlessly:


Play[mx, my] = Play[mx, my] + 1

Any ideas why?

Here’s something stranger…


    for y = 1 to 9
        for x = 1 to 9
            Xn[x, Orig[x, y]] = 0
            Yn[y, Orig[x, y]] = 0
            if(Orig[x, y] > 0) then
                Xn[x, Orig[x, y]] = Xn[x, Orig[x, y]] + 1
                Yn[y, Orig[x, y]] = Yn[y, Orig[x, y]] + 1
            end if
        end for
    end for
                Xn[x, Orig[x, y]] = Xn[x, Orig[x, y]] + 1

It runs through the loop just fine. But fails on the line outside the loop…
Do I have a defective box???

In the words of Homer Simpson…

“Doh!”

I wasn’t initializing correctly, so anything that wasn’t initialized, was set to “invalid” and you can’t add 1 to “invalid”… :roll: