Code: Select all
if tDueDate - tDate is between 86400 and 864000 then
set the backgroundColor of fld "fld1" to yellow
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Code: Select all
if tDueDate - tDate is between 86400 and 864000 then
set the backgroundColor of fld "fld1" to yellow
Code: Select all
red
---------------
2
yellow
4
----------------
green
Code: Select all
put tDueDate - tDate into tTime
if tTime > 86400 and < 604800 then
set the backgroundColor of fld "fldDueDate" to yellow
end if
Code: Select all
button "Button": compilation error at line 17 (Expression: double binary operator) near "<", char 21
Code: Select all
[code]
put tDueDate - tDate into tTime
if tTime > 86400 and tTime < 604800 then
set the backgroundColor of fld "fldDueDate" to yellow
end if
Code: Select all
put the system date into tDate1
convert tDate1 to seconds
put tDate1 into tDate
put fld "fldDueDate" into tDueDate1
convert tDueDate1 to seconds
put tDueDate1 into tDueDate
put tDueDate - tDate into tTime
if tTime < 604800 then
set the backgroundColor of fld "fldDueDate" to red
end if
if tTime >= 86400 and tTime <= 604800 then
set the backgroundColor of fld "fldDueDate" to yellow
end if
put tDueDate - tDate into tTime
if tTime > 604800 then
set the backgroundColor of fld "fldDueDate" to green
end if
Guess I didn't do to bad then. I'm sure it took me about 10000 times longer to do it than you though, but that's ok.jacque wrote:...... I was able to write the entire handler in 17 lines...............
Code: Select all
on mouseUp
put the seconds into tTodaySec
put tTodaySec + (86400 * 8) into t8Day
put tTodaySec + 86400 into t1Day
put fld "fld1" into tDate
convert tDate to seconds
if tDate > t8Day then //if the date hasn't arrived yet stay green
set the backgroundColor of fld "fld1" to green
else if tDate <= t1Day then //if date is date or expired turn red
set the backgroundColor of fld "fld1" to red
else //if date is within 7 days of coming due turn yellow
set the backgroundColor of fld "fld1" to yellow
end if
end mouseUp
jacque wrote:Great! Just for comparison, here's what I put together. I was able to reduce it to 14 lines:When you use "else if" instead of individual "if" statements, LC will execute the first matching condition and ignore all the rest. That's why this handler doesn't need to compare whether the 7-day seconds falls within a range, because if it is more than 7 days the first "if" condition will run and then the handler will skip to the end and exit. That's also why the second condition checks for an overdue, since that will eliminate the situation where the date is today's date or earlier. If it doesn't meet either of those conditions (the "else" line) then the date must fall between today and 8 days from now.Code: Select all
on mouseUp put the seconds into tTodaySec put tTodaySec + (86400 * 8) into t8Day put tTodaySec + 86400 into t1Day put fld "fld1" into tDate convert tDate to seconds if tDate > t8Day then //if the date hasn't arrived yet stay green set the backgroundColor of fld "fld1" to green else if tDate <= t1Day then //if date is date or expired turn red set the backgroundColor of fld "fld1" to red else //if date is within 7 days of coming due turn yellow set the backgroundColor of fld "fld1" to yellow end if end mouseUp