Looking for a way around using portinterval to set C1 off on a CR300 during weekends. My current code i've tested is as follows:
if TimeIntoInterval(480,1440,min) then
PortSet(C1,1)
elseif TimeIntoInterval(1200,1440,min) then
PortSet(C1,0)
elseif TimeIntoInterval (5,7,Day) or TimeIntoInterval (6,7,Day) then
Portset(C1,0)
endif
I turn the port on every morning and off at night. I was hoping for weekends to have it turned off, but this code just gets overwritten during Saturdays and Sundays.
Any suggestions?
You can nest an if statement inside another if statement. Or, you can AND conditions together. I prefer the newer TimeIsBetween instruction as well versus TimeIntoInterval. TimeIsBetween looks to see if you are within a time range, instead of one particular time.
I would approach it as checking to see if you are within the range of days, and the range of time you want to be on.
If TimeIsBetween (2,6,7,Day) AND TimeIsBetween (480,1200,1440,min) Then PortSet(C1,1) Else PortSet(C1,0) EndIf
Great, Thanks!