I (accidentally) referenced a method in an object for which it wasn't defined. Code following that line does not execute, but I get no error message. This makes it very difficult (time consuming) to debug. Why is there no error message? I can't believe this is an unfixed bug, so why am I suffering (build 782)?
And even more strange is what happens when I do add the missing method - then I do get a message to say it doesn't exist!!!!!! How can that happen?
This is my day one of EFS writing and I get two (see earlier post) weird, time-wasting, "bugs". What am I doing wrong?
Later - a PS: I noticed that where I called the missing method I had omitted the argument (name = mark), but no error I see, JavaScript is too lax for my liking! Having put that argument in I no longer see "Printtest undefined" - of course "undefined" referred to the argument, not the method. However this still leaves me puzzling over how to cope with missing methods and the lack of any error message.
And even more strange is what happens when I do add the missing method - then I do get a message to say it doesn't exist!!!!!! How can that happen?
This is my day one of EFS writing and I get two (see earlier post) weird, time-wasting, "bugs". What am I doing wrong?
Later - a PS: I noticed that where I called the missing method I had omitted the argument (name = mark), but no error I see, JavaScript is too lax for my liking! Having put that argument in I no longer see "Printtest undefined" - of course "undefined" referred to the argument, not the method. However this still leaves me puzzling over how to cope with missing methods and the lack of any error message.
PHP Code:
var bStudyInit = false;
var asipsOneSymSet = null;
// function for method
function Printtest2(mark) {
debugPrint("Printtest " + mark + "\n");
}
// make object
function SymInvPair(sSym, nInv) { //
this.sSym = sSym;
this.nInv = nInv;
this.Printtest = Printtest2;
this.Printtest("sip Constructor");
debugPrint("SIP: " + this.sSym + "," + this.nInv + " \n");
}
// make another object, unlike "SymInvPair" this one has no method "Printtest", BUT when I call the (missing) method the program "hangs", and does not error.
// HOWEVER, when I do add the method (just duplicate the " this.Printtest = Printtest2;" line from above I then get an error message "Printtest undefined". This is really incomprehensible - I now get the error message I expect when there is an error when the error doesn't exist?????
function SymInvSet(Sym) { // Type is "sis"
this.sip60 = new SymInvPair(Sym,60);
}
function preMain() {
setStudyTitle("Test1 - No error for missing method");
setCursorLabelName("Test1");
}
function main() {
if ( bStudyInit == false ) {
asipsOneSymSet = new SymInvSet(getSymbol());
debugPrint("Script is loading 2\n");
bStudyInit = true;
}
if (getBarState() == BARSTATE_ALLBARS) {
return;
}
if (getBarState() == BARSTATE_NEWBAR) {
debugPrint("The first tick of a new bar has arrivedA\n");
asipsOneSymSet.Printtest(); // By accident this references a method that does not exist (in this object). I get no error message!!!!!
// The program does not execute this following line, how am I meant to detect this type of error?
// (See debug output is just the line "The first tick of a new bar has arrivedA", not the "B" version)
// If I add the missing method to SymInvSet I get the totaly unexpected "Printtest undefined" message!!!!
debugPrint("The first tick of a new bar has arrivedB\n");
}
return 0;
}
Comment