The numbering rules are subject to change at each release -- and thus are undocumented. Scripts that work in 7.0 wont' necessarily work in 9.0.
If you need to do selections, it is better to refer/select by locations. More rigorous is the ability to query the last created entity...
If it...