Day as value

General questions about Firewing...

Day as value

Postby AndrewB » Thu Oct 27, 2016 1:54 pm

How do I check for the day of the week.
I want to check if it's a week day?

if date.dayofweek >=1 and date.dayofweek <=5 then dosomething
AndrewB
 
Posts: 94
Joined: Thu Jan 02, 2014 3:38 pm

Re: Day as value

Postby AndrewB » Thu Oct 27, 2016 6:52 pm

Ok I had found that that case dependant. DatOfWeek.

I have tried if (((time.hour >= Starthour) and (time.minute >= Startmin)) and ((time.hour < Stophour) and (time.minute < Stopmin))) then

But this does not work. What am I doing wrong on this?

If i ONLY HAVE MINS OR HOUR ITS OK.
AndrewB
 
Posts: 94
Joined: Thu Jan 02, 2014 3:38 pm

Re: Day as value

Postby Jerry Messina » Fri Oct 28, 2016 10:18 am

Firewing isn't case sensitive.

It's best to post a complete example of something that you're trying to do, otherwise it's hard to comment on what's working or not.
Jerry Messina
 
Posts: 280
Joined: Thu Feb 14, 2013 10:16 am

Re: Day as value

Postby AndrewB » Fri Oct 28, 2016 11:28 am

Jerry why does

if (((time.hour >= Starthour) and (time.minute >= Startmin)) and ((time.hour < Stophour) and (time.minute < Stopmin))) then

if time.hour >= Starthour and time.minute >= Startmin and time.hour < Stophour and time.minute < Stopmin then

not work and

If time.hour >= Starthour and time.hour < Stophour then

If time.minute >= Starmin and time.minute < Stopmin then

works
AndrewB
 
Posts: 94
Joined: Thu Jan 02, 2014 3:38 pm

Re: Day as value

Postby Jerry Messina » Fri Oct 28, 2016 8:42 pm

Code: Select all
Public Structure RtcTime
   dim Second As Byte         ' Second (0..59)
   dim Minute As Byte         ' Minute (0..59)
   dim Hour As Byte           ' Hour   (0..11 or 0..23)
End Structure

dim time as RtcTime

dim Starthour, Startmin, Stophour, Stopmin as byte

Sub Main()

time.hour = 2
time.Minute = 34

starthour = 1
startmin = 2

stophour = 3
stopmin = 45

if (((time.hour >= Starthour) and (time.minute >= Startmin)) and ((time.hour < Stophour) and (time.minute < Stopmin))) then
   high(PORTB.0)
end if

If time.hour >= Starthour and time.hour < Stophour then
   If time.minute >= Startmin and time.minute < Stopmin then
      high(PORTB.0)
   end if
end if

End Sub


works the same for me. What's your code look like?
Jerry Messina
 
Posts: 280
Joined: Thu Feb 14, 2013 10:16 am

Re: Day as value

Postby AndrewB » Sat Oct 29, 2016 9:25 am

Thanks Jerry yes it works I had changed a few things and now that looks like it works.

I had to change stop.hour < stophour to stop.hour <= stophour

I will post the program when I've tidy'd up :) I have to work out functions to cut down some of the subs down.
AndrewB
 
Posts: 94
Joined: Thu Jan 02, 2014 3:38 pm

Re: Day as value

Postby AndrewB » Sat Oct 29, 2016 10:59 am

It works if the realtime is before the start and stop times.


If the starthour/startmin is set before the real time it does not seem to go past the startmin/stopmin check.

I think it needs the hours and minutes combined into one variable to compare.
AndrewB
 
Posts: 94
Joined: Thu Jan 02, 2014 3:38 pm


Return to Questions

Who is online

Users browsing this forum: No registered users and 2 guests

cron

x