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

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

Rama TitoProgrammerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gskTechnology consultantCommented:
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
0
Paul JacksonSoftware EngineerCommented:
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.
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rama TitoProgrammerAuthor Commented:
cheers, i looking over and over but couldn't see it.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.