Home > Back-end >  ReferenceError: LE1DOWNmachen is not defined
ReferenceError: LE1DOWNmachen is not defined

Time:11-03

I wrote it in one of the hmi design programs. It´s IoT software. After connecting with the source (my fall Siemens Logo 8) - PLC hardware, I get the ReferenceError, when I click on every button. These are my triggers to fire up the function. They are connected to start the animation. What should I change to get rid of this errors? Thanks, RJ

var TUP= function fAUFmachen() {
var animateAUF2 = LeitstandSCHENKERRadeburg.getElementById('animateAUF2');
var animateAUF3 = LeitstandSCHENKERRadeburg.getElementById('animateAUF3');
var animateAUF4 = LeitstandSCHENKERRadeburg.getElementById('animateAUF4');
var animateAUF5 = LeitstandSCHENKERRadeburg.getElementById('animateAUF5');
var animateAUF6 = LeitstandSCHENKERRadeburg.getElementById('animateAUF6');
var animateAUF7 = LeitstandSCHENKERRadeburg.getElementById('animateAUF7');
var animateAUF8 = LeitstandSCHENKERRadeburg.getElementById('animateAUF8');
var animateAUF9 = LeitstandSCHENKERRadeburg.getElementById('animateAUF9');

 animateAUF2.beginElement();
 animateAUF3.beginElement();
 animateAUF4.beginElement();
 animateAUF5.beginElement();
 animateAUF6.beginElement();
 animateAUF7.beginElement();
 animateAUF8.beginElement();
 animateAUF9.beginElement();
}

var TDOWN= function fZUmachen() {
var animateZU2 = LeitstandSCHENKERRadeburg.getElementById('animateZU2');
var animateZU3 = LeitstandSCHENKERRadeburg.getElementById('animateZU3');
var animateZU4 = LeitstandSCHENKERRadeburg.getElementById('animateZU4');
var animateZU5 = LeitstandSCHENKERRadeburg.getElementById('animateZU5');
var animateZU6 = LeitstandSCHENKERRadeburg.getElementById('animateZU6');
var animateZU7 = LeitstandSCHENKERRadeburg.getElementById('animateZU7');
var animateZU8 = LeitstandSCHENKERRadeburg.getElementById('animateZU8');
var animateZU9 = LeitstandSCHENKERRadeburg.getElementById('animateZU9');

 animateZU2.beginElement();
 animateZU3.beginElement();
 animateZU4.beginElement();
 animateZU5.beginElement();
 animateZU6.beginElement();
 animateZU7.beginElement();
 animateZU8.beginElement();
 animateZU9.beginElement();
}

var LE1UP= function LE1UPmachen() {
var LE1animateUP = LeitstandSCHENKERRadeburg.getElementById('LE1animateUP');
 LE1animateUP.beginElement();
}

var LE1DOWN= function LE1DOWNmachen() {
var LE1animateDOWN = LeitstandSCHENKERRadeburg.getElementById('LE1animateDOWN');
 LE1animateDOWN.beginElement();
}

var LE2UP= function LE2UPmachen() {
var LE2animateUP = LeitstandSCHENKERRadeburg.getElementById('LE2animateUP');
 LE2animateUP.beginElement();
}

var LE2DOWN= function LE2DOWNmachen() {
var LE2animateDOWN = LeitstandSCHENKERRadeburg.getElementById('LE2animateDOWN');
 LE2animateDOWN.beginElement();
}

var LAUP= function LAUPmachen() {
var LAanimateUP = LeitstandSCHENKERRadeburg.getElementById('LAanimateUP');
 LAanimateUP.beginElement();
}

var LADOWN= function LADOWNmachen() {
var LAanimateDOWN = LeitstandSCHENKERRadeburg.getElementById('LAanimateDOWN');
 LAanimateDOWN.beginElement();
}

var ULUP= function ULUPmachen() {
var ULanimateUP = LeitstandSCHENKERRadeburg.getElementById('ULanimateUP');
 ULanimateUP.beginElement();
}

var ULDOWN= function ULDOWNmachen() {
var ULanimateDOWN = LeitstandSCHENKERRadeburg.getElementById('ULanimateDOWN');
 ULanimateDOWN.beginElement();
}

var AUP= function AUPmachen() {
var AanimateUP = LeitstandSCHENKERRadeburg.getElementById('AanimateUP');
 AanimateUP.beginElement();
}

var ADOWN= function ADOWNmachen() {
var AanimateDOWN = LeitstandSCHENKERRadeburg.getElementById('AanimateDOWN');*/
 AanimateDOWN.beginElement();
}

fAUFmachen();
fZUmachen();
LE1UPmachen();
LE1DOWNmachen();
LE2UPmachen();
LE2DOWNmachen();
LAUPmachen();
LADOWNmachen();
ULUPmachen();
ULDOWNmachen();
AUPmachen();
ADOWNmachen();
TUPmachen();
TDOWNmachen();
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

CodePudding user response:

Your code calls

LE1DOWNmachen()

But the only function definition that contains that label is this:

var LE1DOWN= function LE1DOWNmachen() {
   var LE1animateDOWN = LeitstandSCHENKERRadeburg.getElementById('LE1animateDOWN');
   LE1animateDOWN.beginElement();
}

But this code is not defining a function called LE1DOWNmachen(). It is actually equivalent to this:

var LE1DOWN = function() {
   var LE1animateDOWN = LeitstandSCHENKERRadeburg.getElementById('LE1animateDOWN');
   LE1animateDOWN.beginElement();
}

The LE1DOWNmachen is meaningless here. It is being ignored. To invoke this function, you need to call

LE1DOWN();

Demo:

var LE1DOWN = function LE1DOWNmachen() {
  console.log("Here!");
}

// This works
LE1DOWN();

// But this throws a reference error
LE1DOWNmachen();
<iframe name="sif2" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

If you want the function to be called LE1DOWNmachen, then define it like this:

function LE1DOWNmachen() {
  console.log("Here!");
}

or this

var LE1DOWNmachen = function() {
  console.log("Here!");
}

If you want both names to work, you can do this:

function LE1DOWNmachen() {
  console.log("Here!");
}

var LE1DOWN = LE1DOWNmachen;
  • Related