Its a distance between points (attacker and attacked unit)
Than you can do whatever with it. Its just distance between points.
Its an exsample in my spell pack, here in my signature(click on the glowing picture) and than is there a spell called "Deadly Throw" that deals bonus damage, depends on the distance. Pretty much what you are looking for.
P.s. if you didn't read how to make it auto cast, read a tutorial(i think its autocast in dota)