Jump to content

Recommended Posts

Posted

I am thinking what I want to do might not be possible with LISP, but maybe someone much smarter than me can point me in the right direction.

 

Basically I was thinking of how someone could have a subscription based software, that stops working if the customer no longer wants to pay to use it.

 

I would think that when the program runs in AutoCAD, it would need to check the web server if it is still subscribed, then do its routine, else doesn't work.

 

Any ideas how to go about something like this? I can't think how this could be done with lisp, but maybe another programming language then? Perhaps .NET?

 

Also I don't think checking the server every time the routine is called is very efficient, perhaps someone knows a better way?

 

Would love everyones thoughts on this. I have managed to write Licencing parts into lisp before, but not via a conection to a web server that checks daily.

 

Thanks,

Posted

lee-mac has a check web server example, only run it once per autocad session.

 

;;---------------------=={ Internet Time }==------------------;;
;;                                                            ;;
;;  Returns the date and/or UTC time as a string in the       ;;
;;  format specified. Data is sourced from a NIST server.     ;;
;;------------------------------------------------------------;;
;;  Author: Lee Mac, Copyright © 2011 - [url="http://www.lee-mac.com"]www.lee-mac.com[/url]       ;;
;;------------------------------------------------------------;;
;;  Arguments:                                                ;;
;;  format - string specifying format of returned information ;;
;;           using the following identifiers to represent     ;;
;;           date & time quantities:                          ;;
;;           YYYY = 4-digit year                              ;;
;;           YY   = Year, MO = Month,   DD = Day              ;;
;;           HH   = Hour, MM = Minutes, SS = Seconds          ;;
;;------------------------------------------------------------;;
;;  Returns:  String containing formatted date/time data      ;;
;;------------------------------------------------------------;;
(defun LM:InternetTime ( format / result rgx server xml )
   (setq server "[url]http://time.nist.gov:13[/url]")
   (setq result
       (vl-catch-all-apply
           (function
               (lambda ( / str )
                   (setq xml (vlax-create-object "MSXML2.XMLHTTP.3.0"))
                   (setq rgx (vlax-create-object "vbscript.regexp"))
                   (vlax-invoke-method xml 'open "POST" server :vlax-false)
                   (vlax-invoke-method xml 'send)
                   (if (setq str (vlax-get-property xml 'responsetext))
                       (progn
                           (vlax-put-property rgx 'global     actrue)
                           (vlax-put-property rgx 'ignorecase actrue)
                           (vlax-put-property rgx 'multiline  actrue)
                           (setq str (strcat " " (itoa (jtoy (+ (atoi (substr str 2 5)) 2400000.5))) (substr str 7)))
                           (mapcar
                               (function
                                   (lambda ( a b )
                                       (vlax-put-property rgx 'pattern a)
                                       (setq format (vlax-invoke rgx 'replace format b))
                                   )
                               )
                              '("YYYY" "YY" "MO" "DD" "HH" "MM" "SS")
                              '( "$1"  "$2" "$3" "$4" "$5" "$6" "$7")
                           )
                           (vlax-put-property rgx 'pattern
                               (strcat
                                   "(?:[^\\d]+)([\\d]+)(?:[^\\d]+)([\\d]+)"
                                   "(?:[^\\d]+)([\\d]+)(?:[^\\d]+)([\\d]+)"
                                   "(?:[^\\d]+)([\\d]+)(?:[^\\d]+)([\\d]+)"
                                   "(?:[^\\d]+)([\\d]+)(?:.+)\\n"
                               )
                           )
                           (vlax-invoke-method rgx 'replace str format)
                       )
                   )
               )
           )
       )
   )
   (if xml  (vlax-release-object xml))
   (if rgx  (vlax-release-object rgx))
   (if (vl-catch-all-error-p result)
       (prompt (vl-catch-all-error-message result))
       result
   )
)
;; Julian Date to Calendar Year - Lee Mac
;; Algorithm from: Meeus, Jean.  Astronomical Algorithms.
(defun jtoy ( j / a b c d )
   (setq j (fix j)
         a (fix (/ (- j 1867216.25) 36524.25))
         b (+ (- (+ j 1 a) (fix (/ a 4))) 1524)
         c (fix (/ (- b 122.1) 365.25))
         d (fix (/ (- b (fix (* 365.25 c))) 30.6001))
   )
   (fix (- c (if (< 2 (fix (if (< d 14) (1- d) (- d 13)))) 4716 4715)))
)
(vl-load-com) (princ)

Posted

Thanks BIGAL, I will look into this and see if I can get it to work the way i want. Really appreciate your input. I have been searching around for a long time trying to work this out.

Posted

You can auto compile your lisps to fas as well saves a bit of time.

Posted

ok, thaks for the tip.

I am having trouble understanding the code/ All I want to do is read a text file from a website - http://thirdistudio.com.au/TestInfo.txt

 

I don't need to do any formatting, just read the text file.

 

Any ideas how to make that work?

 

Thanks

Posted (edited)

It was so easy, Full credit to Lee-mac though

 

(defun pingserver ( / xml str)
(setq server "http://thirdistudio.com.au/TestInfo.txt") ; I would change this to get passed a unique filename
(setq xml (vlax-create-object "MSXML2.XMLHTTP.3.0"))
(vlax-invoke-method xml 'open "POST" server :vlax-false)
(vlax-invoke-method xml 'send)
(setq str (vlax-get-property xml 'responsetext))
; got your file !!!!!

;do your bit here

(if xml  (vlax-release-object xml))
)

Edited by BIGAL
Updated version fixed missing bracket
Posted

ok, thanks for that, I really appreciate it. It is working for me now, although you might want to edit your code to add another parenthesis to the end of :vlax-false - not so much for me, but anyone else who might just copy and post the code not realising why its not working and will just get a malformed list error....(I love those errors, especially when there are hundreds of lines of code.)

Again, thank very much.

Posted (edited)

Thank you for the recommendation BIGAL :thumbsup:

 

Be careful not to create multiple instances of the MSXML object, and also ensure that you release all references of this object as AutoCAD will not automatically release such objects from memory!

Edited by Lee Mac
Posted

Thanks guys fixed must have copied and pasted incorrectly, Lee I was wondering about how to close the link I just guessed a bit about the code ans was suprised how simple. Tried "CLOSE" instaed of open but the vlax-release does the same.

 

Andrew this should be a defun in your code rather than part of the greater code look at creating a library of functions much easier than constantly repeating code. One of my works had around 69 defuns in the library.lsp, do say (CHECKSECURITY HARDISK) here is a hard disk ID routine this is pretty good method for locking software get end user to run a program send a encrypted version to you send back the master code with this file id.txt ie rename testinfo.txt as part of the software.

 

For full credit, go to Lee-mac.com and look for HDserial number win7.lsp

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...