Page 1 of 1

If statement

Posted: Thu Jul 09, 2009 6:21 am
by Glenn Boyce
The if statement below doesn't work and I don't understand why. The variables are converted dates (to seconds) and it does not show up as a syntax error. Any thoughts? The if statement lies inside a repeat loop. I'm trying to sort items between two dates. It looks like it should work.

Code: Select all

if tdate1 < tstartdate < tdate2 then
    put number of lines of mydata into tlineNo
    put line n of fld "Orders" into line tlineNo + 1 of mydata
    end if

Posted: Thu Jul 09, 2009 7:53 am
by SparkOut
Your conditional statement needs to resolve to one boolean result, true or false.
Try

Code: Select all

if tdate1 < tstartdate and tstartdate < tdate2 then 
It would also (IMHO) be a good practice (especially in the case of more complicated multiple conditional tests, where it can be absolutely necessary) to put each condition into parentheses like

Code: Select all

if (tdate1 < tstartdate) and (tstartdate < tdate2) then 
so you can clearly see the separate comparisons.

Posted: Thu Jul 09, 2009 10:37 pm
by Glenn Boyce
got it. Thank you