Creating tool license function

4 views (last 30 days)
adi kul
adi kul on 27 Feb 2018
Edited: Guillaume on 28 Feb 2018
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') ;
and in my script I have put:
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.
Rik on 27 Feb 2018
You could also either hard-code the implementation of now (so t=datenum(builtin('clock'));), or get the time from the internet.
But even if you do, your m-file can be changed, p-code can be decompiled (and reduces the number of releases that will run your code), and time servers can be spoofed. It is always an arms race. Every creator will almost always be on the losing end.

Sign in to comment.

Accepted Answer

Guillaume on 27 Feb 2018
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') ;
adi kul
adi kul on 28 Feb 2018
This actually helped. Thanks Guillaume!

Sign in to comment.

More Answers (0)


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!