August 11, 200619 yr Hi All, I need a script that will give me a warning based on due date. For example: The due date is (September 1, 2006) Current Date (August 12, 2006) Three months before the due date I need the DB to warn me July 1, 2006 a warning "Reminder" text in green color One month before the due date August 1, 2006 a warning "Warning" text in yellow color Two weeks before the due date August 17, 2006 a warning "Urgent" text in red and blinking Then a check box that the user will check if the task is already delt with. Then the warning field will be empty. Thank you all in advance. Edited August 11, 200619 yr by Guest
August 11, 200619 yr Case( Date(Month(Get(CurrentDate)); Day(Get(CurrentDate)); Year(Get(CurrentDate))) >= date_due and Date(Month(Get(CurrentDate)); Day(Get(CurrentDate)) - 14; Year(Get(CurrentDate))) <= date_due and IsEmpty(task_done); TextColor("Urgent"; RGB(200; 0; 0)); Date(Month(Get(CurrentDate)); Day(Get(CurrentDate)) - 14; Year(Get(CurrentDate))) >= date_due and Date(Month(Get(CurrentDate)) - 1; Day(Get(CurrentDate)); Year(Get(CurrentDate))) <= date_due and IsEmpty(task_done); TextColor("Warning"; RGB(255; 225; 50)); Date(Month(Get(CurrentDate)); Day(Get(CurrentDate)) - 1; Year(Get(CurrentDate))) >= date_due and Date(Month(Get(CurrentDate)) - 3; Day(Get(CurrentDate)); Year(Get(CurrentDate))) <= date_due and IsEmpty(task_done); TextColor("Reminder"; RGB(0; 200; 0)) )
August 11, 200619 yr Author Thank you very much Sir Osborne, perfecto (I started learning FM8 from your lecture with VTC now moving to advance module fyi)
August 11, 200619 yr I prefer this style - taking advantage of short-circuiting (new since vs. 7) and it would save 3 evaluations. By testing for Task_Done outside the entire calc, we can save 3 more evaluations. And the entire calc won't bother to calculate at all if task is done (taking advantage of branch prediction), saving more evaluations. I also find it easier to read in this format: If ( IsEmpty ( TaskDone ) and DueDate ; Let ( [ today = Get ( CurrentDate ) ; urgent = today + 14 ; warning = Date ( Month ( today ) + 1 ; Day ( today ) ; Year ( today ) ) ; reminder = Date ( Month ( today ) + 3 ; Day ( today ) ; Year ( today ) ) ] ; Case ( urgent :great: DueDate ; TextColor ( "Urgent"; RGB ( 200; 0; 0 ) ) ; warning :great: DueDate ; TextColor ( "Warning"; RGB ( 255 ; 225 ; 50 ) ) ; reminder :great: DueDate ; TextColor ( "Reminder"; RGB ( 0; 200; 0 ) ) ; ) ) ) John, your calc doesn't work unless the DueDate is the current date or passed. I suppose you have DevCon on your mind! LaRetta :wink2: Edited August 12, 200619 yr by Guest Added note to John ...
August 12, 200619 yr Author Hi Sir LaRetta, Just checked the calc of Mr. John and seems not working maybe i did something wrong? By the way thanks for the the new calc. Looks very easy now, that was the cal I was thinking the first time around, but I was really confused, I think there's not enough logic in my head. I saw that kind of calc with the age calc example from this forum. Thanks again Edited August 12, 200619 yr by Guest
August 12, 200619 yr You didn't set your calc to unstored which it needs to be because it uses Get ( CurrentDate). If you change that, you will see what I mean. But here's the comparison. It breaks because (I think) John copy/pasted the pieces and didn't correct them properly. I doubt his mind is here with us today - it's off at DevCon where I wish *I* was! :wink2: test.zip
Create an account or sign in to comment