My client complained that she is constantly forgetting to check indexes, and would like a reminder to check if she has not done so for 30 days.
I have written a small piece of code (OK, converted Action Script to Xbasic) to do this, but cannot get it to work.
I have a configuration table containing a field called Indexcheckdate that stores the date the indexes were last checked (Type = Date). When the code runs, this date is retrieved and stored in a variable called "indexdate". The date should then be checked against today's date to see if 30 days have passed. If not, no action should be taken.
The dialog box always displays, even when the value of indexdate variable is less than 30 days before today's date (verified by text in dialog box). I am guessing there is something wrong with the line "IF a5_eval_expression("=(date()- Var->indexdate > 30)") THEN ", but I don't know what.
I have written a small piece of code (OK, converted Action Script to Xbasic) to do this, but cannot get it to work.
I have a configuration table containing a field called Indexcheckdate that stores the date the indexes were last checked (Type = Date). When the code runs, this date is retrieved and stored in a variable called "indexdate". The date should then be checked against today's date to see if 30 days have passed. If not, no action should be taken.
The dialog box always displays, even when the value of indexdate variable is less than 30 days before today's date (verified by text in dialog box). I am guessing there is something wrong with the line "IF a5_eval_expression("=(date()- Var->indexdate > 30)") THEN ", but I don't know what.
Code:
DIM indexdate AS D 'get date indexes last checked tbl = table.open("configuration") indexdate = tbl.Indexcheckdate tbl.close() 'Check if 30 days have passed since indexes were last checked IF a5_eval_expression("=(date()- Var->indexdate > 30)") THEN 'Displays a message box. DIM indexreminder_result as N DIM indexreminder_YES_Button as L DIM indexreminder_NO_Button as L indexreminder_YES_Button = .F. indexreminder_NO_Button = .F. title_var = "Check Indexes" 'Message is an expression. Need to evaluate the expression in the context of the current form. message_text_var = a5_eval_expression("=\"You have not checked the table indexes for 30 days.\"+chr(13)+chr(10)+\"Would you like to check them now?\"+chr(13)+chr(10)+chr(13)+chr(10)+\"Indexes last checked on \" + Var->indexdate",local_variables()) indexreminder_result=ui_msg_box(title_var,message_text_var,UI_YES_NO+ UI_FIRST_BUTTON_DEFAULT+ UI_ATTENTION_SYMBOL) 'Test to see which button on the message box was pressed.... SELECT CASE indexreminder_result = UI_YES_SELECTED indexreminder_YES_Button= .t. CASE indexreminder_result = UI_NO_SELECTED indexreminder_NO_Button= .t. END SELECT END IF 'If user clicks on "Yes" button IF indexreminder_YES_Button THEN a5_CheckIndexesDialog(controlpanel.Active()) 'Update indexcheckdate to today's date dim tbl as P tbl = table.open("configuration") tbl.change_begin() tbl.Indexcheckdate = date() tbl.change_end(.T.) tbl.close() END IF
Comment