Thank you Barry for the code, I am trying to adapt it to put data into a file I have on my web server.
I think I have butchered it somehow....
I tried, maybe I have not formated something properly?
I am really not sure about how to format the new data to push into the file.....
Based on what you had, I think it follows the file path? I tried " this is new data for the file"....
Thanks for the help, I know I am asking for a lot of help, I just am really stuck with this :P
This is what I tried.....
(defun push ()
(setq webObj nil)
(setq strUrl (strcat "http://stampingsolutionsgroup.com/rcmtool/stationformdata/formdata_bob.txt" " this is new data for the file"))
(setq webObj (vlax-invoke-method (vlax-get-acad-object) 'GetInterfaceObject "WinHttp.WinHttpRequest.5.1"))
(vlax-invoke-method webObj 'Open "GET" strUrl :vlax-true)
(vlax-invoke-method webObj 'Send)
);end defun
That's definitely not going to work.... :)
You're just sending a URL to a file named "formdata_bob.txt this is new data for the file"
You need to send "this is new data for the file" as an argument to a PHP file & have the PHP file pars the arguments & write to the "formdata_bob.txt" file.
I'll see if a can but a working example together...
OK I think I got a little working example for ya.
(Note; I know very little PHP, I just hacked this together from the PHP Tutorial link I gave you before)
Try this:
(defun push (file temp1 temp2 / )
(setq webObj nil)
(setq strUrl (strcat "http://www.opendcl.com/temp/FileWrite.php?file=" file "&temp1=" temp1 "&temp2=" temp2))
(setq webObj (vlax-invoke-method (vlax-get-acad-object) 'GetInterfaceObject "WinHttp.WinHttpRequest.5.1"))
(vlax-invoke-method webObj 'Open "GET" strUrl :vlax-true)
(vlax-invoke-method webObj 'Send)
);end defun
(push "formdata_bob.txt" "Hello" "World")
PHP code:
<?php
//get variables from URL
$myFile = $_GET['file'];
$temp1 = $_GET['temp1'];
$temp2 = $_GET['temp2'];
//Open file & write to it
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $temp1 . "/t";
fwrite($fh, $stringData);
$stringData = $temp2 . "/t";
fwrite($fh, $stringData);
fclose($fh);
//echo variables for debugging in the browser, not returned to Lisp
echo $myFile . "/t";
echo $temp1 . "/t";
echo $temp2 . "/t";
?>
This assumes the .PHP & .TXT file are in the same folder, has no error checking or security.
I'll leave these file up in the "www.opendcl.com/temp (//http://) (//http://) (//http://)" folder for you to play with, but will take them down in a few day.
Hope this helps...
Barry
Thanks Barry, I think I am getting it now, I will give it a try!
I tried that method, it would not allow me access to the temp directory Barry listed, something about permisions....
So I tweaked the code to point at my web server.... but it does not seem to work.
So I entered the commands in one at a time on the command line making sure the StrURl was set first.
It returns nil where it should be opening the web object, I am guessing this is not what it should do....
Any thoughts?
Command: *Cancel*
Command: !strurl
"http://www.stampingsolutionsgroup.com/home/wihon/public_html/bquinn/FileWrite.p
hp?file=formdata_bob.txt&temp1=Hello&temp2=World"
Command: (setq webObj (vlax-invoke-method (vlax-get-acad-object)
'GetInterfaceObject "WinHttp.WinHttpRequest.5.1")) #<VLA-OBJECT IWinHttpRequest
0bae4100>
Command: (vlax-invoke-method webObj 'Open "GET" strUrl :vlax-true)
nil
Command: (vlax-invoke-method webObj 'Send)
nil
File used is below....
(defun push (file temp1 temp2 / )
(setq webObj nil)
(setq strUrl (strcat "http://www.stampingsolutionsgroup.com/home/wihon/public_html/bquinn/FileWrite.php?file=" file "&temp1=" temp1 "&temp2=" temp2))
(setq webObj (vlax-invoke-method (vlax-get-acad-object) 'GetInterfaceObject "WinHttp.WinHttpRequest.5.1"))
(vlax-invoke-method webObj 'Open "GET" strUrl :vlax-true)
(vlax-invoke-method webObj 'Send)
);end defun
Did you put "FileWrite.php" & "formdata_bob.txt" on your web server?
When I go to: http://www.stampingsolutionsgroup.com/home/wihon/public_html/bquinn/FileWrite.php (http://www.stampingsolutionsgroup.com/home/wihon/public_html/bquinn/FileWrite.php)
or: http://www.stampingsolutionsgroup.com/home/wihon/public_html/bquinn/formdata_bob.txt (http://www.stampingsolutionsgroup.com/home/wihon/public_html/bquinn/formdata_bob.txt)
I get file not found, so it don't look like it....
Yes these 2 lines always return nil
(vlax-invoke-method webObj 'Open "GET" strUrl :vlax-true)
(vlax-invoke-method webObj 'Send)
Hi Barry, I will work on the path, its hard to tell where the stuff is at with the Cpanel interface, (or maybe its just my lack of web-site understanding!)
Thanks, Bob.
o.k. I think I got the paths correct, but no go still......
http://stampingsolutionsgroup.com/bquinn/formdata_bob.txt (http://stampingsolutionsgroup.com/bquinn/formdata_bob.txt)
OK you got 1 out of 2 done:
http://stampingsolutionsgroup.com/bquinn/FileWrite.php (http://stampingsolutionsgroup.com/bquinn/FileWrite.php)
Still has File not found....
Hi Barry, thanks for all your help! I think we got it going, something about case sensitive paths, and they didn't match or something!
Thanks for all your help!