NicePerson 1 Posted August 14, 2010 (edited) This script works fine before compiling but why it does not work after compiling? After compiling when i run this error comes: Error: Subscript used with non-Array Variable #include <INet.au3> $aPasses = StringRegExp(_INetGetSource('http://www.sitename.com'),"update=..", 3) If StringReplace($aPasses[0],'update="', "") = 1 Then MsgBox(0, "", "Update is available") _Update() Else MsgBox(0, "", "Update is not available") EndIf Func _Update() Local $hDownload = InetGet("http://www.sitename.com/NewVersion.exe", @ScriptDir & "\NewVersion.exe", 1, 1) Do Sleep(250) Until InetGetInfo($hDownload, 2) ; Check if the download is complete. InetClose($hDownload) ; Close the handle to release resourcs. Run(@ScriptDir & "\NewVersion.exe") EndFunc Edited August 14, 2010 by RMR Share this post Link to post Share on other sites
trancexx 1,013 Posted August 14, 2010 Because $aPasses is not an array then. ♡♡♡ . eMyvnE Share this post Link to post Share on other sites
FlyinRiz 0 Posted August 14, 2010 My guess is it's failing at the StringReplace because the StringRegExp never returned a match (and therefore an array) Try adding... If @error = 0 Then MsgBox(0, "", "Keyword Update not found") EndIf ...right after the StringRegExp statement like this... $aPasses = StringRegExp(_INetGetSource('http://www.sitename.com'),"update=..", 3) If @error = 0 Then MsgBox(0, "", "Keyword Update not found") EndIf If StringReplace($aPasses[0],'update="', "") = 1 Then MsgBox(0, "", "Update is available") _Update() Else MsgBox(0, "", "Update is not available") EndIf That should tell you if it's failing or not. -Aaron Share this post Link to post Share on other sites
NicePerson 1 Posted August 14, 2010 Because $aPasses is not an array then.Any other way? Share this post Link to post Share on other sites
Tvern 11 Posted August 14, 2010 (edited) Any other way?No. If that's your whole script that is definately the problem. Look at FlyinRiz' post for a solution.<h3></h3>Edit: Where did the header tags come from? Edited August 14, 2010 by Tvern Share this post Link to post Share on other sites
JohnOne 1,603 Posted August 14, 2010 @error = 0 means that that the array is valid. Look at the helpfile for @error codes, but you definately should have error checking. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Share this post Link to post Share on other sites
FlyinRiz 0 Posted August 14, 2010 @error = 0 means that that the array is valid.Look at the helpfile for @error codes, but you definately should have error checking.Yea thx...I'm not reading that well...working on an all night server rebuild at work. Share this post Link to post Share on other sites
NicePerson 1 Posted August 14, 2010 My guess is it's failing at the StringReplace because the StringRegExp never returned a match (and therefore an array) Try adding... If @error = 0 Then MsgBox(0, "", "Keyword Update not found") EndIf ...right after the StringRegExp statement like this... $aPasses = StringRegExp(_INetGetSource('http://www.sitename.com'),"update=..", 3) If @error = 0 Then MsgBox(0, "", "Keyword Update not found") EndIf If StringReplace($aPasses[0],'update="', "") = 1 Then MsgBox(0, "", "Update is available") _Update() Else MsgBox(0, "", "Update is not available") EndIf That should tell you if it's failing or not. -Aaron I tried this but problem not solved!! Now what i should do? Share this post Link to post Share on other sites
4ggr35510n 0 Posted August 14, 2010 (edited) #include <INet.au3> Global $actual_version_of_program = "1.01" $aPasses = StringRegExp(_INetGetSource('http://www.sitename.com'),'update.?=.?([0-9]\x2e[0-9]{2})', 3) If IsArray($aPasses) Then MsgBox(0,"Preparing for update...","Your version of program is " & $actual_version_of_program & @LF & @LF & "On server there is version " & $aPasses[0]) Else MsgBox(0,"Error", "Server webpage in unavaible or doesn't containt string 'update'") EndIf Pattern 'update.?=.?([0-9]\x2e[0-9]{2})' will returns every number followed by dot followed by two numbers, IF there is string update followed by any character or "=" followed by any character or not... In example: Update = 1.05 ---> returns 1.05 Update=1.23 ---> returns 1.23 Update?=#1.00 ---> returns 1.00 Update 1.43 ---> DOESNT MATCH Updte = 1.11 ---> DOESNT MATCH Update=_1.11 ---> returns 1.11 Edited August 14, 2010 by 4ggr35510n Share this post Link to post Share on other sites