Sign in to follow this  
Followers 0
brizoke

Some understanding

5 posts in this topic

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 this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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.

Share this post


Link to post
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
Sign in to follow this  
Followers 0