Jump to content

Error: Subscript used with non-Array Variable


Recommended Posts

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 by RMR
Link to comment
Share on other sites

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

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

#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 by 4ggr35510n
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...