TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: El Bachaco on November 12, 2014, 10:44:58 AM

Title: Uptime
Post by: El Bachaco on November 12, 2014, 10:44:58 AM
Greetings friends .... I can include you as a lisp routine that run only a certain time ..... thanks for the help and your time .......!
Title: Re: Uptime
Post by: ChrisCarlson on November 12, 2014, 11:47:04 AM
You want to know how to run a lisp routine at a certain time of the day?
Title: Re: Uptime
Post by: El Bachaco on November 12, 2014, 01:47:19 PM
hi chris ..... I want the routine is executed only eg for a month.......
Title: Re: Uptime
Post by: ChrisCarlson on November 12, 2014, 01:51:19 PM
So it runs for a month and stops?
Title: Re: Uptime
Post by: El Bachaco on November 12, 2014, 02:38:23 PM
yes.....Chris.....
Title: Re: Uptime
Post by: ChrisCarlson on November 12, 2014, 03:09:39 PM
Would probably just be easier to make an Outlook reminder to unload the routine.

Code - Auto/Visual Lisp: [Select]
  1. (defun c:WantsTheD (/ currentD FutureD)
  2.         (setq   currentD (rtos (getvar "CDATE")2 8)
  3.                         FutureD (rtos 20141212.00000000 2 8)
  4.         )
  5.         (if
  6.                 (< currentD futureD)
  7.                         (alert"\nGood to Go")
  8.                         (alert "\nToo Late")
  9.         )
  10. )

But here is my stab
Title: Re: Uptime
Post by: El Bachaco on November 12, 2014, 03:18:11 PM
hey Chris thank you very much ....... I write to try ....
Title: Re: Uptime
Post by: ChrisCarlson on November 12, 2014, 03:26:01 PM
What is the purpose? Sounds like a trial period or register for a full version?
Title: Re: Uptime
Post by: El Bachaco on November 12, 2014, 03:32:19 PM
yes .... is a routine test metal structure .... thanks for your interest Chris
Title: Re: Uptime
Post by: ChrisCarlson on November 12, 2014, 03:36:16 PM
This isn't really a valid way to do that. You'd have to manually edit the LISP routine before you sent it out. You could look into registry edits and creating keys on first run. I'd suggest submitting it through the AutoDesk exchange, from what I understand they incorporate purchases / trials. I could be wrong though.
Title: Re: Uptime
Post by: El Bachaco on November 12, 2014, 03:44:09 PM
Chris ....... I am from Venezuela, Latin America, and the routine is to work at the company where I work and putting on parole for that company policy .....!
Title: Re: Uptime
Post by: hermanm on November 12, 2014, 07:34:46 PM
to start, look up the DATE system variable in  AutoCAD help.

Code - Auto/Visual Lisp: [Select]
  1. Command: (getvar "date")
  2. 2.45697e+006
  3.  

next, investigate these functions:

Code - Auto/Visual Lisp: [Select]
  1. vl-registry-read
  2.  

Have fun. :)

Title: Re: Uptime
Post by: El Bachaco on November 13, 2014, 11:45:22 AM
many thanks hermanm.....
Title: Re: Uptime
Post by: mailmaverick on November 14, 2014, 12:28:15 PM
The DATE solution suggested may not work if the user changes system date.

Is there any other fool proof method ?


Title: Re: Uptime
Post by: VovKa on November 14, 2014, 12:59:07 PM
The DATE solution suggested may not work if the user changes system date.

Is there any other fool proof method ?
one can query internet time
Title: Re: Uptime
Post by: mailmaverick on November 14, 2014, 01:02:41 PM
The DATE solution suggested may not work if the user changes system date.

Is there any other fool proof method ?
one can query internet time

Yes Good Option, What is the LISP code to query internet time ?

Title: Re: Uptime
Post by: VovKa on November 14, 2014, 02:20:53 PM
Yes Good Option, What is the LISP code to query internet time ?
http://www.theswamp.org/index.php?topic=33065.0
Code: [Select]
(vk_ReadXML "http://developer.yahooapis.com/TimeService/V1/getTime?appid=YahooDemo")
Code: [Select]
(defun vk_UnixTime2AcadTime (u) (+ 2440588.0 (/ u 86400.0)))
Title: Re: Uptime
Post by: Lee Mac on November 15, 2014, 06:44:16 AM
The DATE solution suggested may not work if the user changes system date.

Is there any other fool proof method ?
one can query internet time

Yes Good Option, What is the LISP code to query internet time ?

Another:
http://www.theswamp.org/index.php?topic=39491.msg447974#msg447974
Title: Re: Uptime
Post by: hermanm on November 15, 2014, 01:39:52 PM
nice job, Lee.:)

Note that NIST:

http://tf.nist.gov/tf-cgi/servers.cgi

is recommending ntp as replacement for the old "DAYTIME" protocol

thus:
Code - Auto/Visual Lisp: [Select]
  1. (setq server "ntp://time.nist.gov/");newer protocol
  2.  

works here.

@ mailmaverick:
yes, true enough.
by default, though, Windows systems are set to sync with a time server
so, it takes a conscious act to de-sync system time,
which would result in all local time stamps becoming inaccurate.
Is it likely someone would do that, just to run an expired AutoLISP demo?
I think not, but perhaps I am mistaken.

In any case, locks only keep out the honest folks.
JMO.
Title: Re: Uptime
Post by: Lee Mac on November 15, 2014, 05:38:38 PM
nice job, Lee.:)

Note that NIST:

http://tf.nist.gov/tf-cgi/servers.cgi

is recommending ntp as replacement for the old "DAYTIME" protocol

thus:
Code - Auto/Visual Lisp: [Select]
  1. (setq server "ntp://time.nist.gov/");newer protocol
  2.  

works here.

Many thanks Herman  :-)

I haven't revisited the code in 3 years (wow - that's gone by fast!), so thank you for the heads-up on the new server url.

Lee
Title: Re: Uptime
Post by: El Bachaco on November 15, 2014, 06:49:39 PM
thanks guys for all your help .....!
Title: Re: Uptime
Post by: MeasureUp on March 29, 2015, 09:19:37 PM
I was wondering if querying internet time is possible then finally end up to this nice thread. Thanks to everyone.
I tried Lee's code but find this does not work:
Code: [Select]
(setq server "ntp://time.nist.gov/")
unless use the old one:
Code: [Select]
(setq server "http://time.nist.gov:13")

And the page is not exist anymore:
http://tf.nist.gov/tf-cgi/servers.cgi

Can you please confirm if the 2nd one above is still correct?
Many thanks.
Title: Re: Uptime
Post by: VovKa on March 30, 2015, 06:30:24 AM
there's yet another way to query internet time
Code: [Select]
(defun vk_GetRemoteFileHeaders (RemoteFileName Headers / objHTTP Result)
  (if (setq objHTTP (vlax-create-object "WinHTTP.WinHTTPRequest.5.1"))
    (progn (setq Result (vl-catch-all-apply
  (function
    (lambda ()
      (vlax-invoke-method objHTTP "Open" "HEAD" RemoteFileName :vlax-false)
      (vlax-invoke objHTTP "Send")
      (if (= (vlax-get-property objHTTP "Status") 200)
(mapcar (function (lambda (h / r)
    (setq r (vl-catch-all-apply
      'vlax-invoke-method
      (list objHTTP "GetResponseHeader" h)
    )
    )
    (cons h
  (if (not (vl-catch-all-error-p r))
    r
  )
    )
  )
)
Headers
)
      )
    )
  )
)
   )
   (vlax-release-object objHTTP)
   (if (and Result (not (vl-catch-all-error-p Result)))
     Result
   )
    )
  )
)
Code: [Select]
(defun vk_GetInternetTime (/)
  (cdar (vk_GetRemoteFileHeaders "http://www.google.com" (list "Date")))
)
any server can be used, even http://www.theswamp.org :)
Title: Re: Uptime
Post by: ur_naz on March 30, 2015, 09:36:28 AM
While any VL Application can be decompiled you cannot protect it any code you write
Title: Re: Uptime
Post by: El Bachaco on March 30, 2015, 05:09:13 PM
friends ..... thank you very much to all of you for your work and time.......
Title: Re: Uptime
Post by: mailmaverick on April 01, 2015, 02:40:05 PM
While any VL Application can be decompiled you cannot protect it any code you write

How can a VLX be decompiled into LISP code ?