TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: matrix2005in on June 30, 2006, 01:54:08 PM
-
hi i need to set current date + 30 for expiry date how can i do that?? i tried to add +30 to start date but it gives error..
(defun bomb ()
(setq bombif (getvar "cdate"));;getsthe current date
(if (> 20010829.00000000 bombif);i need to set expiry date as start date+30
(alert "you are in")
(princ "\Version Expired!")
)
)
-
add 100
-
thanks
but where and how that will work
if you dont mind can you explain little...
-
You should actually check the 3rd and 4th digits to the left of the decimal. If they are 2 and 1 respectively then instead of adding 100, you need to add 8900.
The number CDATE gives you isn't actually a number, it just looks like one. it is YYYYMMDD.HHMMSSSS
You're probably better off using DATE instead of CDATE. There's a thread around here somewhere, I'll try to turn it up.
-
http://www.theswamp.org/index.php?topic=10405.0
-
hi CAB code is good but little change is required...i would like to get final date instead of number of days between two dates...and that would be start date + 30 is there anyway to do that???
(defun c:test ()
;; Month Day Year
(print (DaysBetween 1 1 2006 1 2 2006))
(print (DayOfYear 12 31 2006))
(princ)
)
(defun DaysBetween (m1 d1 y1 m2 d2 y2)
(fix (- (ctoj y2 m2 d2 0 0 0) (ctoj y1 m1 d1 0 0 0)))
)
(defun dayOfYear (m d y / year)
(if (= y (setq year (fix(/(getvar "CDATE") 10000))))
(1+ (fix (- (ctoj y m d 0 0 0) (ctoj year 1 1 0 0 0)))))
)
thanks
-
Can you use this?
(load "julian")
(setq cdate (getvar "date"))
(princ "\nStart date: ")
(princ (jtoc cdate))
(setq futuredate (+ cdate 30))
(princ "\nEnding date: ")
(princ (jtoc futuredate))
-
Jeff thanks very much...
one more help if you can...is there any other code available same like jtoc....... many of my machines are not loaded with express tools........
-
Have a look at the JULIAN.lsp code. There's nothing magic in there, in fact it does a VERY thorough job of describing HOW it works along with references. It wouldn't be too difficult to duplicate what it does.......especially since you only really need a small bit of it.
On second thought, here's one I put together a few years ago that will handle another type of date (that which MS File System Objects use).....
;;function to convert a computer standard serial date,
;; such as what TDCREATE returns, to a calendar date.
;; If FSO? is not nil then the input date is treated as
;; a MS date as returned by the FileScriptingObject
;; Jeff Mishler c. 2003
(defun ser2cal (serdate FSO?)
(if FSO?
(setq serdate (+ serdate 2415019))
)
(menucmd
(strcat "M=$(edtime,"
(rtos serdate 2 8)
",DDD\",\" DD MON YYYY hh:mm)"));;change as desired, see ACAD help for syntax
)
Then in use similarly to my previous post:
(setq cdate (getvar "date"))
(princ "\nStart date: ")
(princ (ser2cal cdate nil))
(setq futuredate (+ cdate 30))
(princ "\nEnding date: ")
(princ (ser2cal futuredate nil))
This returns:
Start date: Sat, 01 Jul 2006 16:19
Ending date: Mon, 31 Jul 2006 16:19
-
... or
;; set hardcoded timeStamp plus 1 month.
;; (setq tmp (rtos (+ (getvar "CDATE") 100.00) 2 2))
;; => "20060802.11"
(setq expiryDate 20060802.11)
(COND ((= (GETVAR "CDATE") expiryDate)
(ALERT "The end of the world is nigh ... ")
)
((> (GETVAR "CDATE") expiryDate)
(ALERT "beware the ninja in the night ... bye ")
(EXIT)
)
(T (PROMPT "\n Don't worry, be happy. "))
)
edit:
Just don't issue this in December :-)
-
Or.....this can be used anytime during the year :-)
;;when installing......
(setq installDate (fix (getvar "date")))
(vl-registry-write "HKEY_CURRENT_USER\\Software\\JMM-Utils\\Install" "Date" installdate)
;;when validating date
(defun runproduct ()
;;this is the code you will run if the time period is OK
(princ "...it's running")
(princ)
)
(setq installDate (vl-registry-read "HKEY_CURRENT_USER\\Software\\JMM-Utils\\Install" "Date")
curDate (fix (getvar "date"))
diff (- curdate installDate)
)
(cond ((> diff 30)
(alert "Your evaluation period has EXPIRED! Please purchase a copy now.")
)
((= diff 30)
(alert "Your evaluation period Expires TODAY! Please purchase a copy now.")
)
(t
(alert (strcat "You have " (itoa (- 30 diff)) " days left to try this product."))
(runproduct);;;
)
)
This is how I adjusted the starting date to check if it works, re-running the appropriate lines for each test.....
;;when installing......
(setq installDate (fix (getvar "date")))
;;;test over 30
(setq installDate (- installdate 45))
;;;test exactly 30
(setq installDate (- installdate 30))
;;;test less than 30
(setq installDate (- installdate 10))
;;visual check
(ser2cal installDate nil)
(vl-registry-write "HKEY_CURRENT_USER\\Software\\JMM-Utils\\Install" "Date" installdate)
-
hi jeff
your code is absolutely fantastic....i really really appreciate that...
thanks man
mathew
-
Matrix...
I have tried and study many thing to get a demo version of my software..
Also, I have tried to make a code with "date".
But this method is easy to bypass by changing the current date of your PC.
BEFORE and AFTER any installation.
I suggest many other method...more secure.
You can use
Password to activate the trial,
generated by the curren MACadress or PC USERNAME ...
ex:
(setq w (vl-string->list (getvar "username")))
(setq str1 "N")
(while w
(setq car1 (rtos (car w)))
(setq str1 (strcat str1 car1 ))
(setq w (cdr w))
)
(alert (strcat "Your activation code is :\n\n" str1))
and use something like...
(setq trial_time (vl-registry-write "HKEY_CURRENT_USER\\Software\\blahblah" "blah_TRIAL_TIME" "30"))
(defun c:trythis ()
(if (or (< (atoi trial_time) 1)
(> (atoi trial_time) 30))
(alert "Your time is expired !")
(progn
(setq trial_time2 (- (atoi trial_time) 1))
(setq trial_time (vl-registry-write "HKEY_CURRENT_USER\\Software\\blahblah" "blah_TRIAL_TIME" (itoa trial_time2)))
(alert (strcat "Software activated for " trial_time " more times."))
)))
but this is my suggestion.... 8-)
-
Andrea, I agree that a user changing the computer's date could lead ti mis-use of the software. However,with so many other things on the computer requiring valid dates I don't think that a relatively small lisp wouyld be worth the effort. And if that user that DOES wish to muck around with date, they are probably also savvy enough to muck around in the registry and change the "bla-TRIAL-TIME" to whatever they desire.......
By using the DATE variable, not many users are going to know that the number 2345234 is referencing a date. More likely, they will think that it is a random number and changing it could render the program useless....especially if the Data Key is not named "Date" or "Expiry", etc. (I know, my example used Date, but it was just an example)
-
Jeff, I agree with you.
a simple little lisp don't require to much effort for protect it...
but some lisp yes.
The code i have posted is a exemple only to show what it'S possible to do.
he can make many other thing if he want....I just put the post to help him to have some idea by himself.
sure you can use something like...
(setq cdate (+ 113877 (read (vl-list->string (reverse (vl-string->list (rtos (getvar "cdate") 2 0)))))))
(vl-registry-write "HKEY_CURRENT_USER\\Software\\WinSpec00" "Data" cdate)
no one never know... :angel:
-
HI andrea
thats a gr8 idea...but how this will work...i mean how i can read the date from this??
thanks
mathew
-
Mathew, like so....just reverse the process he used.
;; I would still use "date" in lieu of "cdate" since you can easily
;; add/subtract days from it without worrying about spanning months & years
(setq cdate (+ 113877 (read (vl-list->string (reverse (vl-string->list (rtos (getvar "date") 2 0)))))))
(vl-registry-write "HKEY_CURRENT_USER\\Software\\WinSpec00" "Data" cdate)
(setq regdate (vl-registry-read "HKEY_CURRENT_USER\\Software\\WinSpec00" "Data"))
(setq regdate (read (vl-list->string (reverse (vl-string->list (rtos (- regdate 113877) 2 0))))))
-
thanks jeff
you are right better to use date..that's very good to easy substraction....yo yo its more better
thanks
mathew
-
it called "reverse enginering".... :wink: