I've got the following attached to the 'OnInit' event on my startup form.
It runs fine as written, but in the event one of the scripts fails for any reason, the lock flag won't be reset to .f. and all users will be locked out of the system.
How can I check for an error and set the lock field back to .f. if this happens?
Thanks!
It runs fine as written, but in the event one of the scripts fails for any reason, the lock flag won't be reset to .f. and all users will be locked out of the system.
How can I check for an error and set the lock field back to .f. if this happens?
Thanks!
Code:
tbl = table.open( "menu" ) IF tbl.lock = .t. 'Displays a message box (style:'OK Button', image: 'Information symbol', id: 'wrning'). DIM SHARED wrning_result as N DIM SHARED wrning_OK_Button as L wrning_OK_Button = .F. title_var = "WARNING" message_text_var = <<%text% WARNING! Another user is currently running daily system maintenance. Please try again in a few minutes. %text% wrning_result=ui_msg_box(title_var,message_text_var,UI_OK+ UI_FIRST_BUTTON_DEFAULT+ UI_INFORMATION_SYMBOL) 'Test to see which button on the message box was pressed.... SELECT CASE wrning_result = UI_OK_SELECTED wrning_OK_Button= .t. END SELECT tbl.close() 'Exit Alpha Five. :a5.close() ELSE CONTINUE tbl.close() END IF tbl = table.open( "Menu" ) IF tbl.date = date() END' ELSE tbl.change_begin() tbl.lock = .t. tbl.date = date() tbl.change_end( .t. ) PleaseWait_fnc(.t.,"Performing Daily Maintenance" ) script_play_local( "Billto_Ageing" ) PleaseWait_fnc(.f.) index_rebuild_auto(.F.) tbl.change_begin() tbl.lock=.f. tbl.change_end( .t. ) tbl.close() END IF END'
Comment