Page 1 of 1

JavaScript won't output values (Check code please)

Posted: Wed Mar 04, 2015 2:03 am
by David Lewis

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


JavaScript won't output values (Check code please)

Posted: Wed Mar 04, 2015 9:46 am
by Illya Stepanov

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.


JavaScript won't output values (Check code please)

Posted: Wed Mar 04, 2015 5:11 pm
by David Lewis

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


JavaScript won't output values (Check code please)

Posted: Wed Mar 04, 2015 8:33 pm
by Alena Prykhodko

JavaScript won't output values (Check code please)

Posted: Wed Mar 04, 2015 8:38 pm
by David Lewis

Now it's showing this: Image


JavaScript won't output values (Check code please)

Posted: Thu Mar 05, 2015 6:14 am
by Egor Kotov6832188

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