ReferenceError: ST_Cal is not define (line 41, col 5);

Rama Tito
Rama Tito used Ask the Experts™
on
i am new to javascript, Error message saying as follows: - "ReferenceError: ST_Cal is not defined (line 41, col 5)"


var Mor;
var diffM;
var delta_sec;
var startCurr;
var startMor;
var ST_Target;
var Shift_Target;
var current;
var M_Start = flow.get('Morning_start');
var M_Stop =flow.get('Morning_end');
var M_sec = flow.get('Morning_sec');
//var M_time;                                     //call function variable
//Var C_Time;                                     //call function varialbe

var M_cycle = flow.get("Cycle_Time");

var dt = new Date();
    var hour = dt.getHours();
    hour = ("0" + hour).slice(-2);
    var minute = dt.getMinutes();
    minute=("0" +minute).slice(-2);
    var sec = dt.getSeconds();
    sec=("0" + sec).slice(-2);

    current = hour+":" +minute+":"+sec;
    
function ST_cal(M_time,C_Time,prodcycle){
    console.log("I am in function");
    var curr = C_Time.split(":");
    Mor = M_time[0].split(":");
    startMor = new Date(0,0,0, Mor[0],Mor[1],Mor[2]);
    startCurr = new Date(0,0,0, curr[0],curr[1],curr[2]);
        
    diffM = startCurr.getTime() - startMor.getTime();
    delta_sec = Math.floor(diffM/1000);
    return(Math.floor((delta_sec)/prodcycle));    
}

if ( current > M_Start[0] && current < M_Stop[0] )
            
    ST_Target = ST_Cal(M_Start[0], current,cycle[0]);   
    msg.paylaod  = ST_Target;


//elseif ( current > M_Start[1] && current < M_Stop[1] )

//        M_sec[0]
//elseif ( current > M_Start[2] && current < M_Stop[2] )
//        M_sec[1]
//elseif ( current > M_Start[3] && current < M_Stop[3] )
//        M_sec[2]
//elseif ( current > M_Start[4] && current < M_Stop[4] )
//        M_sec[3]

return msg; 

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
gskTechnology consultant

Commented:
Hi Rama Tito,

It seems in the code that  below values need to be uncomment as finction ST_cal is taking parameters as M_Time ,C_time and prodcycle,so
please remove the comments
var M_time;                                     //call function variable
Var C_Time;  

and also declare
var prodcycle

hope it helps
Software Engineer
Top Expert 2011
Commented:
Your function is defined as ST_cal (lower case c)
You are trying to call it with ST_Cal (upper case C)

JavaScript is case sensitive for identifiers including function names.
Rama TitoProgrammer

Author

Commented:
cheers, i looking over and over but couldn't see it.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial