# Some understanding

## Recommended Posts

I saw this ocr code on here and want to understand something about it.

CODE
Func _OCR(\$Ax, \$Ay, \$Dx, \$Dy)

\$width = \$Dx - \$Ax

\$length = \$Dy - \$Ay

Dim \$char[\$width][\$length]

For \$xwidth = 0 To \$width - 1

For \$xlength = 0 To \$length - 1

\$char[\$xwidth][\$xlength] = Hex(PixelGetColor(\$Ax, \$Ay), 6)

\$Ay = \$Ay + 1

Next

\$Ax = \$Ax + 1

\$Ay = \$Ay - \$length

Next

;scans entire area

What I don't understand is how this piece of code works. In the second for loop, \$xlength starts at zero and is supposed to stop at \$length , but the loop gets incremented by - 1. Shouldn't that be + 1. I am sorry if this is a dumb question, but if someone can illistrate it for me I would really appreciate it.

##### Share on other sites

If you are speaking of this line:

`For \$xlength = 0 To \$length - 1oÝ÷ Ù8bJÖ¬jëh×6For \$xlength = 0 To (\$length - 1)`

xlength does not get decremented by 1

[or as you put it "incremented by -1"]

-MSP-

Edit: to decrement you would use Step -1, I think...

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

##### Share on other sites

If you are speaking of this line:

`For \$xlength = 0 To \$length - 1oÝ÷ Ù8bJÖ¬jëh×6For \$xlength = 0 To (\$length - 1)`

xlength does not get decremented by 1

[or as you put it "incremented by -1"]

-MSP-

Edit: to decrement you would use Step -1, I think...

Thank you very much. I see now that there is no Step in the loop. I am very new to this obviously. I really appreciate your help.

##### Share on other sites

You are welcome... and welcome to the forum.

Hang around, it is a great community.

[size="1"][font="Arial"].[u].[/u][/font][/size]

##### Share on other sites

You are welcome... and welcome to the forum.

Hang around, it is a great community.

Agree.

i542

P.S. Don't be as others: post a question and leave.

Edited by i542

I can do signature me.

## Create an account

Register a new account

×

• Wiki

• Back

• Git