TimeOk till 3.31pm

#11
Following are original code, running fine on my pc.

Please help me to add timeOK check.



function GetSecondNum()
{
Time = Now( 4 );
Seconds = int( Time % 100 );
Minutes = int( Time / 100 % 100 );
Hours = int( Time / 10000 % 100 );
SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
return SecondNum;
}

RequestTimedRefresh( 1 );

tn = TimeNum();
startTime = 091759; // start in HHMMSS format
endTime = 155059; // end in HHMMSS format

timeOK = tn >= startTime AND tn <= endTime;

TimeFrame=60;
SecNumber = GetSecondNum();
Newperiod = SecNumber % TimeFrame == 0;
SecsLeft = SecNumber - int( SecNumber / TimeFrame ) * TimeFrame;
SecsToGo = TimeFrame - SecsLeft;



if ( NewPeriod ) // every 1 min copying chart as image and this is running fine using this since last 1 year, hence pls help me to add timeOK check.


{
ShellExecute("wscript.exe", "intraday.js", ".\\Scripts"); // AND TimeNum()<=130659 ; //AND today !=0 OR today !=6 ;
}
@Slindia: I think if you add TimeOK to your NewPeriod i.e.
if(NewPeriod and TimeOK)
{..............} it should work. Thnx
 

mastermind007

Well-Known Member
#14
Try

If(selectedvalue(newPeriod and timeOK))
 
#15
I tried

If(newPeriod and selectedvalue(timeOK))

Also I tried

If(NewPeriod and TimeOK)

Above Both are not working.
@Slindia : In that case I believe values in your StartTime and EndTime should be as given in the code below. Hope it helps. Thnx.
Code:
StartTime = Paramtime("Define Start Time","09:14:59",0);//Start at 09:15 hours.
EndTime = Paramtime("Define End Time","15:29:59",0);//this will end at 15:30 hrs.
 
#16
Thank you so much for prompt reply,

I will implement above codes.

But then how to control following to run between startTime and endTime

if ( NewPeriod )
{
ShellExecute("wscript.exe", "intraday.js", ".\\Scripts");
}
 
#17
Thank you so much for prompt reply,

I will implement above codes.

But then how to control following to run between startTime and endTime

if ( NewPeriod )
{
ShellExecute("wscript.exe", "intraday.js", ".\\Scripts");
}
@Slindia : Your if statement must include (NewPeriod and TimeOK) to satisfy both conditions for your "ShellExecute........"
 
#18
What complex method has been invented to do a super simple task. AFL is calling Windows Script Host, which in turn creates an ActiveX Amibroker object and calls the amibroker back to take picture of the graph.

Why don't you use the code that I supplied earlier and encapsulate the timing logic in the WSH.

Use timing function of Jscript

While (1)
{setTimeout(function(){ //Place the code here }, 1000); }

Alternatively you can use windows task scheduler.