David Lewis
Posts: 0
Joined: Sun Mar 01, 2015 9:06 pm

JavaScript won't output values (Check code please)

Can someone check my code blocks?

INPUT:

var majd = Number(Apperyio("majd").val());

if (majd === 0) {
alert ("Please enter number 0.");
return;
}

var TPI = Number(Apperyio("TPI").val());

if (TPI === 0) {
alert ("Please enter number 0.");
return;
}

var n = Number(Apperyio("n").val());

if (n === 0) {
alert ("Please enter number 0.");
return;
}

var tlength = Number(Apperyio("tlength").val());

if (tlength === 0) {
alert ("Please enter number 0.");
return;
}

var offset = Number(Apperyio("offset").val());

var feed = 1/TPI ;
var k = 0.759/TPI;
var mind = majd-(k2);
var d = k/(n0.5);
var xcham = mind-0.005;
var zcham = 0-feed;
var g54x = majd+0.05;
var g54z = 3feed;
var zthread = tlength+offset;

localStorage.setitem('majd',majd);
localStorage.setItem('feed',feed);
localStorage.setItem('k',k);
localStorage.setItem('mind',mind);
localStorage.setItem('d',d);
localStorage.setItem('xcham',xcham);
localStorage.setItem('zcham',zcham);
localStorage.setItem('g54x',g54x);
localStorage.setItem('g54z',g54z);
localStorage.setItem('zthread',zthread);

OUTPUT:

var feed = localStorage.getItem('feed');
var k = localStorage.getItem('k');
var mind = localStorage.getItem('mind');
var xcham = localStorage.getItem('xcham');
var zcham = localStorage.getItem('zcham');

var g54x = localStorage.getItem('g54x');
var g54z = localStorage.getItem('g54z');
var decmd = localStorage.getItem('decmd');
var zthread = localStorage.getItem('zthread');
var d = localStorage.getItem('d');

Appery('feedout').text(feed);
Appery('kout').text(k);
Appery('mindout').text(mind);
Appery('xchamout').text(xcham);
Appery('zchamout').text(zcham);

Appery('code').text('G00 G54 x'+g54x+'z'+g54z);
Appery('code2').text('G76 F'+feed+' X'+decmd+' Z'+zthread+' K'+k+' D'+d);

THIS IS WHAT POPS UP:

Image

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

JavaScript won't output values (Check code please)

Hi David -

1) Open browser console.
2) Expand stacktrace for exception, which you will see.
3) Click one by one on the line number in the stacktrace until you will find your code as a result.

Since feed variable is null, it means you have exception somewhere in the input.

David Lewis
Posts: 0
Joined: Sun Mar 01, 2015 9:06 pm

JavaScript won't output values (Check code please)

You're going to have to dumb it down a bit please.

David Lewis
Posts: 0
Joined: Sun Mar 01, 2015 9:06 pm

JavaScript won't output values (Check code please)

Now it's showing this: Image

Egor Kotov6832188
Posts: 0
Joined: Wed Nov 19, 2014 5:15 pm

JavaScript won't output values (Check code please)

HI David,

1) Have you tried to open console?
2) Any math operation that involves incorrect numbers will give NaN as a result

3) Create new javascript file. Add to it all your variables from input, so they all will be in global scope and remove word 'var' before them

Return to “Issues”