Shop OBEX P1 Docs P2 Docs Learn Events
if command with no comparison — Parallax Forums

if command with no comparison

TJHJTJHJ Posts: 243
edited 2008-09-08 20:07 in Propeller 1
So I was looking at the TSL230 light to frequency driver, and for the auto scaling part, in which it changes the state of two pins to determine the scale.
The command call, places a true or false in auto.·
So it then evaluates the following
if auto                                               'autoscaling code
    if val > 1_000_000                                  'if output exceeds 1 MHz, decrease gain
      scale := --scale #> 1
    elseif val < 10_000                                 'if output less than 10 kHz, increase gain
      scale := ++scale <# 3
    outa := scale << cbase

changing which pins are high/low to set the scale. So where I am lost is in the if evaluation. I just had it in my mind a if statement it must be followed by a evaluation.

I am guessing that if auto == true it performs the evaluation?

False does nothing, leaving the two output pins as they were previously set.
·I just wanted to make sure this is correct?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-09-08 20:07
    The IF must be followed by an expression. If the expression evaluates to a non-zero value, the IF clause is executed, otherwise the ELSE (or ELSEIF) clause is executed. Read the documentation on the IF statement.

    "if auto" is equivalent in behavior to "if auto <> 0"
Sign In or Register to comment.