Uncaught TypeError: Unable to read property '1' from null

Im getting an error message: Uncaught TypeError: Unable to read property '1' from null Source: X.push (check [1]);

what is the problem?

wspolrzedne.value = text typed in textArea: "2.4 5 1 67 15 67"

So maybe the problem is that titanium does not protect this line with \ n as a new line?

var coordinates = wspolrzedne.value.split( "\n" ); var X = []; var Y = []; for( var i = 0; i < coordinates.length; ++i ) { var check = coordinates[ i ].match( /^([0-9]+.[0-9]*) ([0-9]+.[0-9]*)$/ ); if( check == false) { var zlewspolrzedne = Ti.UI.createAlertDialog({ title: "Niew?a?ciwe wspรณ?rz?dne: " + coordinates[ i ], buttonNames: ['Popraw'], cancel: 0 }); zlewspolrzedne.show(); } X.push( check[ 0 ] ); Y.push( check[ 1 ] ); } 
+6
source share
1 answer

This is because textArea doesn't care about linebreaks , just a space. So the solution is to divide by ' ' , and then combine each of the two (or feed each pair directly into the control array and check their contents on the fly).

Edit:

So the problem is in this line:

 var check = coordinates[ i ].match( /^([0-9]+.[0-9]*) ([0-9]+. [0-9]*)$/ ) 

It assigns only one value instead of two.

+2
source

Source: https://habr.com/ru/post/948503/


All Articles