Jump to content

Subscript used with no-array variable


Recommended Posts

Hi,

In testing as an .au3 file it succeeds, but once compiled it fails with "Subscript used with non-array variable".

Any idea why?

$SofieDir = (@ProgramFilesDir & "\Sofie")
$SofieAddIn = ("SofieAddIn.xla")


If Not FileExists($SofieDir) Then DirCreate($SofieDir)

If FileExists($SofieDir & "\" & $SofieAddIn) Then
    $t = FileGetTime($SofieAddIn)
    $mdyyyy = $t[1] & "/" & $t[2] & "/" & $t[0]

    If $mdyyyy = "3/5/2008" Then 
        Exit 
    Else
        FileInstall("SofieAddIn.xla", $SofieDir & "\" & $SofieAddIn, 1)
    EndIf
Else
    FileInstall("SofieAddIn.xla", $SofieDir & "\" & $SofieAddIn, 1)
EndIf

Thanks!!

Edited by stev379
Link to comment
Share on other sites

Perhaps your FileGetTime() function that is defining the array is failing. (i.e. couldn't find the file)

A simple test would be to do this:

$SofieDir = (@ProgramFilesDir & "\Sofie")
$SofieAddIn = ("SofieAddIn.xla")


If Not FileExists($SofieDir) Then DirCreate($SofieDir)

If FileExists($SofieDir & "\" & $SofieAddIn) Then
    $t = FileGetTime($SofieAddIn)
    If @error then Msgbox(0,"Error", "An error occured.") 
    $mdyyyy = $t[1] & "/" & $t[2] & "/" & $t[0]

    If $mdyyyy = "3/5/2008" Then
        Exit
    Else
        FileInstall("SofieAddIn.xla", $SofieDir & "\" & $SofieAddIn, 1)
    EndIf
Else
    FileInstall("SofieAddIn.xla", $SofieDir & "\" & $SofieAddIn, 1)
EndIf

If I had to guess why it would fail, i would say try changing the FileGetTime() parameter to be a full path to the file, because otherwise, it only references @scriptdir

so try this too:

$t = FileGetTime($SofieDir & "\" & $SofieAddIn)
Link to comment
Share on other sites

Perhaps your FileGetTime() function that is defining the array is failing. (i.e. couldn't find the file)

If I had to guess why it would fail, i would say try changing the FileGetTime() parameter to be a full path to the file, because otherwise, it only references @scriptdir

so try this too:

$t = FileGetTime($SofieDir & "\" & $SofieAddIn)

AWESOME! Once again the AutoIT forum saves the day!

Thanks!!

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...