MATLAB: Creating tool license function

date

Hi, I have created a basic tool to calculate few of the formulas which I was working on. Now I have converted into a simple script and want to put a license kind of function which will show "license expired" error upon exceeding the date.
this so far I could put together: in Tool_validity i have:
function Tool_validity
if now > datenum('2018-01-01') % this code stops working Jan 1, 2018
disp('Please update your License') ;
return
end
and in my script I have put:
Tool_validity;
Thing is, after the message, the tool still proceeds to next steps. I don't want it to proceed further. Please let me know how can I make it work.

Best Answer

Well, yes disp only displays the message then proceeds with the next line. error aborts the code:
if now > datenum('2018-01-01') % this code stops working Jan 1, 2018
error('Please update your License') ;
end