Shop OBEX P1 Docs P2 Docs Learn Events
Condition False even though True — Parallax Forums

Condition False even though True

LightfootLightfoot Posts: 228
edited 2010-06-13 10:23 in Propeller 1
Something is acting fishy. The condition I have is not registering as true even though it is.

repeat
    CLK.Set(19, 32, 50) 'Set clock, 19:00 hours, 32 minutes past 19:00, 50 seconds
    currentHr := CLK.CurrentHour
    currentMin := CLK.CurrentMinute
    if currentHr >= 19 and currentHr <= 19 and currentMin >= 32 and currentMin <= 34
      outa[noparse][[/noparse]16]~~
    else
      outa[noparse][[/noparse]16]~




The current hour (currentHr) of the clock is 19 and outa[noparse][[/noparse]16] should go high when the clock hits 19:33. It does not.

What is up?

The application is a lights timer.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2010-06-12 23:52
    if currentHr >= 19 and currentHr <= 19 and currentMin >= 32 and currentMin <= 34
    


    SPIN can be a bit awkward sometimes. Replace >= with => (the former is an assignment, the latter the comparison) and <= with =<.

    Post Edited (kuroneko) : 6/13/2010 12:10:05 AM GMT
  • tmaynardtmaynard Posts: 27
    edited 2010-06-13 01:27
    kuoneko said...
    SPIN can be a bit awkward sometimes. Replace >= with => (the former is an assignment, the latter the comparison) and <= with =<.
    I stumbled over these until I saw the pattern: the "=" on the right is always an assignment operator. Think +=, -=, and /= ... all have equals on the right, all are assignment operators common in many languages.

    At first Spin's assignment operators just seemed weird, but now they make perfect sense. You just have to see the pattern. They're the logical extension of already familiar operators.

    Tom.
  • RossHRossH Posts: 5,519
    edited 2010-06-13 10:23
    ... and some people say C is obscure !!!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Catalina - a FREE C compiler for the Propeller - see Catalina
Sign In or Register to comment.