I'd add that LOCATE has for me always been a difficult command in terms of code compatibility: different BASICs implement it in different ways. I once ported some regularly-used statistics calculations over to Liberty BASIC, in the days before QB64 (or at least, before I discovered QB64).
Liberty BASIC implements LOCATE the other way round -- ie, not LOCATE x, y but instead LOCATE y, x...! Which to me is crazy. When I gave up on Liberty BASIC (I felt ripped off on licensing too, which didn't help), I had to convert everything back.
So use LOCATE with caution, is my advice.
Malcolm