|
FiendishX Wanderer
Joined: 19 Nov 2005 Posts: 53
|
Posted: Mon Jun 30, 2008 7:18 pm
#read not working on a generated file |
I'm trying to put together an automatic updater for zMUD scripts, but I've hit a tiny snag.
First, here's the basic script so far:
Code: |
#CLASS {ScriptUpdater} {setdef}
#ALIAS scriptupdate {#MSS {do:Set objHTTP = CREATEOBJECT~(~"MSXML2.ServerXMLHTTP.6.0~"~)~:objHTTP.Open ~"GET~",~"%-1~?%time( "hhnnsszzz")~", FALSE~:on error resume next~:Err.Clear~:objHTTP.Send~:state = objHTTP.readyState~:strHTML = objHTTP.ResponseText~:intX = INSTR~(objHTTP.ResponseText, ~"~<script~>~"~) + 8~:intY = INSTRREV~(objHTTP.ResponseText, ~"~<~/script~>~"~):intZ = intY - intX~:scriptLoc = mid~(objHTTP.ResponseText, intX, intZ~)~:intX = INSTR~(objHTTP.ResponseText, ~"~<install~>~"~) + 9~:intY = INSTRREV~(objHTTP.ResponseText, ~"~<~/install~>~"~):intZ = intY - intX~:installCommands = mid~(objHTTP.ResponseText, intX, intZ~)~:Set objHTTP = Nothing:if state ~<~> 4 then:sleep(2000):end if:loop until state = 4} VBScript;#SHOW %mss( strHTML);#SHOW %mss( scriptLoc);downloadscript %mss( scriptLoc);#VARIABLE installcommands %replace( %mss( installCommands), "SCRIPTFILE", @scriptupdatestorage);#EXECUTE @installcommands}
#ALIAS downloadscript {#MSS {do:Set objHTTP = CREATEOBJECT~(~"MSXML2.ServerXMLHTTP.6.0~"~)~:objHTTP.Open ~"GET~",~"%-1~?%time( "hhnnsszzz")~", FALSE~:on error resume next~:Err.Clear~:objHTTP.Send~:state = objHTTP.readyState~:strHTML = objHTTP.ResponseText~:Set objHTTP = Nothing:if state ~<~> 4 then:sleep(2000):end if:loop until state = 4} VBScript;#MSS {strHTML = Replace(strHTML, vbLf, vbCrLf)};#VARIABLE scriptupdatestorage %concat( %replace( %right( {%session.zMUDFileName("","")}, 2), "\", "/"), "tempscript.txt");#FILE 1 @scriptupdatestorage;#ERASE 1;#FILE 1 @scriptupdatestorage;#WRITE 1 %mss( strHTML);#CLOSE 1}
#VAR scriptupdatestorage {}
#VAR installcommands {}
#CLASS 0
|
This is the content of the update file that gets downloaded by scriptupdate (the url has been changed for this post, but you should get the idea):
Quote: |
<script>http://www.websiteurl.com/scriptfile.txt</script>
<install>#echo hello;#read SCRIPTFILE;#echo done?</install> |
Everything appears to work correctly until it gets to the last part of scriptupdate where it's supposed to, as instructed by the update file, echo "hello", execute the downloaded script, and then echo "done".
It echos "hello" and "done", but it won't read the generated script file. It won't #READ the file from the command line either. I can use #TYPE on the file, so I know that the location is valid, and I can use "Execute script..." from the menu, so I know that the file is (should be) ok. But I need to be able to execute it from inside the update script. Anyone have an idea how to fix or get around this? |
|
|
|
ralgith Sorcerer
Joined: 13 Jan 2006 Posts: 715
|
Posted: Mon Jun 30, 2008 9:18 pm |
You need to call #read properly.... if your file location has any spaces in it you need to make sure it is called with quotes:
Code: |
#READ "C:\Users\Owner\Documents\zMUD Scripts\Banking.txt" |
instead of:
Code: |
#READ C:\Users\Dylan\Documents\zMUD Scripts\Banking.txt |
That is the only reason I've ever not had #READ work. |
|
_________________ CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate |
|
|
|
FiendishX Wanderer
Joined: 19 Nov 2005 Posts: 53
|
Posted: Tue Jul 01, 2008 8:04 am |
I figured out the problem. The problem is that #read uses a different file location format than everything else.
#TYPE and #FILE both access files by using a format like "/Program Files/zMUD/mudfolder/file.txt".
But #READ doesn't do it that way. Oh, no. #READ has to be different. #READ stupidly uses "C:\Program Files\zMUD\mudfolder\file.txt" even though that format doesn't work for #TYPE or #FILE.
Anyway, thanks for helping me come up with that idea in a roundabout way. |
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|