In between decision!

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

In between decision!

Post by jgu1 »

Hi!

Help needed. I am making a project with a GPS module. I am using the time (clock). I want to set an output on or off in between some hours.

Is it possible in an if decision to make a command "if hour is between 3 and 8 then yes or no. So what I mean if a variable is in between two value.

Hope you understand-

Yhanks in advance

Br jorgen
Attachments
Between.PNG
(6.91 KiB) Downloaded 1318 times

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: In between decision!

Post by mnf »

Code: Select all

(hour >= 3) and (hour <= 8)
Or use > and < if it's not inclusive..

Martin

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: In between decision!

Post by jgu1 »

Hi Martin!

Just what I need. Thank you very much for help. :D

Br. Jorgen

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: In between decision!

Post by mnf »

Lookup "Boolean logical operators" in C. The standard operators for examples && || work, and Flowcode helpfully converts 'and' and 'or' into the correct equivalent....

Note also that although parentheses () are not essential - care is needed as sometimes operator precedence can play tricks on you.. Brackets will keep things clearer and stop any surprises so I would recommend their use when combining terms.

Martin

Post Reply