If statement

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Glenn Boyce
Posts: 137
Joined: Thu Jul 24, 2008 11:22 pm

If statement

Post by Glenn Boyce » Thu Jul 09, 2009 6:21 am

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

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Thu Jul 09, 2009 7:53 am

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.

Glenn Boyce
Posts: 137
Joined: Thu Jul 24, 2008 11:22 pm

Post by Glenn Boyce » Thu Jul 09, 2009 10:37 pm

got it. Thank you

Post Reply