Point 3: I have solved the block of point 3 by breaking the code into 2 parts (thanks to trancexx's explanations in posts 6 and 7). xx += sx; xx *= sx = x0 < x2 ? 1 : -1; becomes $xx += $sx $sx = ($x0 < $x2 ? 1 : -1) $xx *= $sx ; /* x step direction */ Point 2: Perhaps the (Long) is just for type conversion, since Autoit manage variable types automatically, I've thougt to simply remove that instruction (and it seems to work...