Parse Error

Javascript problem. Probably newb error but I just don't get it!

usefuldesign.au's picture

I'm writing a simple JS routine to filter a structure of points into those points that are within a prescribed distance of a particular point, which is described by it's index value in the point structure.

So it's not the first time JS has refused to pull nested values even when I'm using code I've used successfully elsewhere ie. [i] ["X"]. And it's not for the first time it refuses to parse a line like:

 total_points = all_points.length;

even though the exact same line works in another patch parsing the same structure data. (so I've used the structure count patch and pull it in ;) )

But this really gets me, as a way of debugging I'm logging some point co-ords (X,Y,Z) as __numbers out of the patch.

If I literally assign them as in result.X = 0.123 no worries but if I use the incredibly complicated code of

var x1 = new Number();
x1 = 2 + 3;
result.X = x1;

I get told Argument X: Incorrect type, should be a number ( :\ x100 )

If anybody can explain this to me I'd be enormously grateful. Shutting down in frustration.

Cheers Alastair