dilan Posted October 20, 2018 Posted October 20, 2018 (edited) Hello everyone! Found a code on the forum: (defun readwwwtxt ( / obj rtn ) (if (setq obj (vlax-get-or-create-object "winhttp.winhttprequest.5.1")) (progn (setq rtn (vl-catch-all-apply (function (lambda ( ) (vlax-invoke-method obj 'open "GET" (strcat "http://www.theswamp.org/lilly.pond/public/GetFileFromURL.txt" ) :vlax-false ) (vlax-invoke-method obj 'send) (vlax-get-property obj 'responsebody) ) ) ) ) (vlax-release-object obj) (if (vl-catch-all-error-p rtn) (princ (vl-catch-all-error-message rtn)) (princ (vl-list->string (mapcar '(lambda ( x ) (lsh (lsh x 24) -24)) (vlax-safearray->list (vlax-variant-value rtn)) ) ) ) ) ) ) (princ) ) This program reads the contents of a text file from the Internet and writes to the command line. Specifically, in this case, it is written to the command line: Test file. Please tell me how I can assign the result of the program to a variable? Tried to do just: (setq simple_variable (readwwwtxt)) But I did not work. Edited October 20, 2018 by dilan Quote
hanhphuc Posted October 20, 2018 Posted October 20, 2018 (edited) hi,simply remove the last (princ) which suppressed the rtn value Edited October 20, 2018 by hanhphuc 1 Quote
dilan Posted October 20, 2018 Author Posted October 20, 2018 54 minutes ago, hanhphuc said: hi,simply remove the last (princ) which suppressed the rtn value thank you Quote
Lee Mac Posted October 20, 2018 Posted October 20, 2018 (edited) Here is the original code for my function: http://www.theswamp.org/index.php?topic=46438.msg514570#msg514570 Here is another implementation of the method: http://www.theswamp.org/index.php?topic=45220.msg504240#msg504240 And here is the likely source of where you found the code in your post: http://www.theswamp.org/index.php?topic=45700.msg508403#msg508403 Edited October 20, 2018 by Lee Mac 2 Quote
Grrr Posted October 20, 2018 Posted October 20, 2018 4 hours ago, Lee Mac said: Here is the original code for my function: http://www.theswamp.org/index.php?topic=46438.msg514570#msg514570 Thank you Lee! Do you know is it possible to access the HTML DOM ? 4 hours ago, Lee Mac said: Here is another implementation of the method: http://www.theswamp.org/index.php?topic=45220.msg504240#msg504240 And here is the likely source of where you found the code in your post: http://www.theswamp.org/index.php?topic=45700.msg508403#msg508403 I've found these too, because OP didn't mentioned the source. 1 Quote
dilan Posted October 20, 2018 Author Posted October 20, 2018 One more question, how to check from lisp internet connection ? Quote
hanhphuc Posted October 21, 2018 Posted October 21, 2018 (edited) 7 hours ago, dilan said: One more question, how to check from lisp internet connection ? I learned a bit 'ipconfig' & 'ping' from telco technician during troubleshoot. eg: ping 192.168.0.1 etc.. my attempt not an elegant way, simply uses windows 'command' ping'ing IP address merely checking for connection Quote ping /? Usage: ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS] [-r count] [-s count] [[-j host-list] | [-k host-list]] [-w timeout] [-R] [-S srcaddr] [-c compartment] [-p] [-4] [-6] target_name i.e: test count = 4 (defun c:ping (/ fn str ret i f ) (alert (strcat "\nConnection is " (if (and (setq fn (strcat (getvar 'tempprefix) "ping.txt")) (vl-cmdf "_.shell" (strcat "ping www. -n 4 > " fn)) (progn (alert "\nChecking internet.. \nOK to continue.") (findfile fn)) (setq f (open fn "r")) (progn (while (setq str (read-line f)) (if (wcmatch str "*#%*") (setq ret str) ) ) (if f (close f) ) ret ) (setq i (mapcar ''((a b) (+ a (vl-string-search b ret))) '(2 1) '("(" "%"))) (zerop (read (substr ret (car i) (apply '- (reverse i))))) ) "OK!" "failed!" ) ) ) (princ) ) Edited October 21, 2018 by hanhphuc sym f localized, ping /? info Quote
Grrr Posted October 21, 2018 Posted October 21, 2018 12 hours ago, dilan said: One more question, how to check from lisp internet connection ? Just browse on google: Is internet connection available Although makes me thing if the readwwtxt returns nil, wouldn't that mean that either the txt file cannont be accessed, or theres no internet connection? 1 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.