Michaels Posted February 14, 2011 Posted February 14, 2011 Is it possible to control a Lisp routine to stop working after passing a specific date and not running even if the user backward the date of the Computer ? Many Thanks Quote
Smirnoff Posted February 14, 2011 Posted February 14, 2011 Something like this. This function returns T if time not yet expired and system time has not been changed. But you can use more secret method than setting environment variables by 'setenv' function. Fore example to write data to Registry or some secret text file. Of course user can every day to set the same date, but it is not convenient. This can also be envisaged. (defun TimeControl(Days / Pass) (if(not(getenv "FirstDate")) (setenv "FirstDate"(itoa(fix(getvar "CDATE")))) ); end if (if(not(getenv "LastDate")) (setenv "LastDate"(getenv "FirstDate")) ); end if (setq lDate(atoi(getenv "LastDate")) fDate(atoi(getenv "FirstDate")) cDate(fix(getvar "CDATE"))) (cond ((> cDate lDate) (alert "Your system time has been changed.\n Bue, bue bad guy... ") ); end condition #1 ((>(- cDate fDate)Days) (alert "Your time has been expired.\n Call me baby. ") ); # end condition #2 (T (setq Pass T) (setenv "LastDate"(itoa(fix(getvar "CDATE")))) ); end condition #3 ); end cond Pass ); end of TimeControl Quote
Michaels Posted February 14, 2011 Author Posted February 14, 2011 But you can use more secret method than setting environment variables by 'setenv' function. Fore example to write data to Registry or some secret text file. Thanks a lot , and highly appreciated. I would like to know more information about the way that registry handling strings with it . So what would you please recommend me about that thing ? Regards. Michaels Quote
Guest kruuger Posted February 14, 2011 Posted February 14, 2011 write to reg: (vl-registry-write "HKEY_CURRENT_USER\\Software\\MyApp" "Day left" "30") read from reg: (vl-registry-read "HKEY_CURRENT_USER\\Software\\MyApp" "Day left") k. Quote
Michaels Posted February 14, 2011 Author Posted February 14, 2011 write to reg: (vl-registry-write "HKEY_CURRENT_USER\\Software\\MyApp" "Day left" "30") read from reg: (vl-registry-read "HKEY_CURRENT_USER\\Software\\MyApp" "Day left") k. Thanks kruuger . So what is the differences between (setenv ) to the registry and yours .. (vl-registry-write "HKEY_CURRENT_USER\\Software\\MyApp" "Day left" "30") and also the second one which is read from ( getenv ) and yours ... (vl-registry-read "HKEY_CURRENT_USER\\Software\\MyApp" "Day left") Appreciated. Quote
Michaels Posted February 14, 2011 Author Posted February 14, 2011 What do you need this for? :lol: Quote
Guest kruuger Posted February 14, 2011 Posted February 14, 2011 write to reg: (vl-registry-write "HKEY_CURRENT_USER\\Software\\MyApp" "Day left" "30") read from reg: (vl-registry-read "HKEY_CURRENT_USER\\Software\\MyApp" "Day left") k. both method are the same. sava data to registry. setenv, getenv - sava data to "autocad environment" (you make a mass there i don't like this) vl.. save data to your specific location - i prefer this k. Quote
Smirnoff Posted February 14, 2011 Posted February 14, 2011 I have some good idea without Registry using and any files. FAS file (compiled LSP file) file can recompile itself with new data on each run with vlisp-compile function. I'll try to implement when there is more time. I'm leaving tomorrow on a business trip to Russia, so that no earlier than Saturday. Quote
Guest kruuger Posted February 14, 2011 Posted February 14, 2011 I have some good idea without Registry using and any files. FAS file (compiled LSP file) file can recompile itself with new data on each run with vlisp-compile function. I'll try to implement when there is more time. I'm leaving tomorrow on a business trip to Russia, so that no earlier than Saturday. it might work. that's clever k. Quote
Michaels Posted February 14, 2011 Author Posted February 14, 2011 I have some good idea without Registry using and any files. FAS file (compiled LSP file) file can recompile itself with new data on each run with vlisp-compile function. I'll try to implement when there is more time. I'm leaving tomorrow on a business trip to Russia, so that no earlier than Saturday. The .FAS and VLX compiled Lisp files are known to me and I do use them when being in need of them . But to deal to registry that would save my efforts to public when I am going to be able to write a program to someone and not to use it for along time. My best wishes for you , and enjoy the trip to Russia. Regards Quote
Michaels Posted February 14, 2011 Author Posted February 14, 2011 Hello , Suppose that the user has updated their Autocad version , would the setenv keep the same first string that sent to the registry from the old version for the first time in the use of the Lisp file ? Thanks Quote
Smirnoff Posted February 14, 2011 Posted February 14, 2011 Suppose that the user has updated their Autocad version , would the setenv keep the same first string that sent to the registry from the old version for the first time in the use of the Lisp file ? Not. Environment variable values stores separately for every AutoCAD version. For example for AutoCAD 2011 in: HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R18.1\ACAD-9006:409\FixedProfile\General\ You should use your own registry key to prevent this. Also my idea in post #9 is good because it is file which will stop working after number of days from the first usage day. It is compiled file and it isn't easy task to understand what you need to change inside it to force it works again. Of course user can make copy of this file before usage and overwrite it each time when program is stop working (if he(she) knows that). However perfect security does not exist, unless of course you do not have a magic crystals from Jupiter which is the hardware key on your program. Quote
Guest kruuger Posted February 14, 2011 Posted February 14, 2011 Hello , Suppose that the user has updated their Autocad version , would the setenv keep the same first string that sent to the registry from the old version for the first time in the use of the Lisp file ? Thanks probably no. but you can do something like this: (defun C:TEST () (kr:TEST_RegApp) (princ (strcat "\n" (getenv "MyVaR"))) (princ) ) (defun kr:TEST_RegApp () (if (not (getenv "MyVar")) (setenv "MyVar" "Default") ) ) anyway i don't prefer get..setenv kruuger Quote
MSasu Posted February 14, 2011 Posted February 14, 2011 I have some good idea without Registry using and any files. FAS file (compiled LSP file) file can recompile itself with new data on each run with vlisp-compile function. I'll try to implement when there is more time. I'm leaving tomorrow on a business trip to Russia, so that no earlier than Saturday. I’m afraid that I see some limitations to this solution: the VLISP_COMPILE function seems to accept only source code, not compiled one. even if you manage it to work with compiled code, there may be an issue when try to replace an opened file (the caller is open for run while you attempt to re-write it). this function has effect only when the VLisp editor is active – as much as I’m aware there is no way to open it programmatically. Regards, Mircea Quote
Michaels Posted February 14, 2011 Author Posted February 14, 2011 anyway i don't prefer get..setenv kruuger Thanks kruuger. But why do not you recommend using setenv in a routine to check for valid date as we have been discussing for now ? Regards. Michaels Quote
Guest kruuger Posted February 14, 2011 Posted February 14, 2011 Thanks kruuger. But why do not you recommend using setenv in a routine to check for valid date as we have been discussing for now ? Regards. Michaels this is autocad place to store variables. it's littering for me. download this http://kojacek.republika.pl/ada.html and run (ada.zip) go to HKEY_CURRENT_USER\Software\CAD.pl\ADA. For me this is a place for this kind of thing kruuger Quote
Michaels Posted February 14, 2011 Author Posted February 14, 2011 go to HKEY_CURRENT_USER\Software\CAD.pl\ADA. For me this is a place for this kind of thing kruuger Your routine would change a text contents to the current date . And regarding to the HKEY_CURRENT...... I couldn't find it in Windows7 , so could you please guide me to it ? Regards Quote
Guest kruuger Posted February 14, 2011 Posted February 14, 2011 Your routine would change a text contents to the current date . And regarding to the HKEY_CURRENT...... I couldn't find it in Windows7 , so could you please guide me to it ? Regards probably something has changed in path but i know that program works on win7. you can find this searching for kojacek & kruuger there are all settings needed to run the program k. k. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.