NicePerson Posted August 14, 2010 Share 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 Link to comment Share on other sites More sharing options...
trancexx Posted August 14, 2010 Share Posted August 14, 2010 Because $aPasses is not an array then. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
FlyinRiz Posted August 14, 2010 Share 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 Link to comment Share on other sites More sharing options...
NicePerson Posted August 14, 2010 Author Share Posted August 14, 2010 Because $aPasses is not an array then.Any other way? Link to comment Share on other sites More sharing options...
Tvern Posted August 14, 2010 Share 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 Link to comment Share on other sites More sharing options...
JohnOne Posted August 14, 2010 Share 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. Link to comment Share on other sites More sharing options...
FlyinRiz Posted August 14, 2010 Share 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. Link to comment Share on other sites More sharing options...
NicePerson Posted August 14, 2010 Author Share 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? Link to comment Share on other sites More sharing options...
4ggr35510n Posted August 14, 2010 Share 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 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now