Jump to content

A Warning script or calculation needed Newbie here again


This topic is 6438 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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.

doc.jpg

Edited by Guest
Link to comment
Share on other sites

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))

)

Link to comment
Share on other sites

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 by Guest
Added note to John ...
Link to comment
Share on other sites

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 by Guest
Link to comment
Share on other sites

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

Link to comment
Share on other sites

This topic is 6438 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.