Sign in to follow this  
Followers 0
Imppilot

Script kind of works or kicks out non-Array var error

9 posts in this topic

Afternoon...so...I can run this script to my hearts content on my machine but when I run it on any other machines I get Line -1 Error Subscript used with Non-Array variable.

CODE

#include <date.au3>

#include <lpr.au3>

#include <file.au3>

#include <Array.au3>

Dim $i = 0

Dim $list[3] ;Array of what lists successfully downloaded

ProgressOn ("LCPD LPR", "Progress: ","",-1, -1, 18)

;Map R

$drive = DriveStatus("R:\")

If $drive == "READY" Then

;Map to LPR data, login is the only thing actually needed

DriveMapAdd("R:", "\\IP\Restricted", 0, "USER", "PASS")

EndIf

ProgressSet(10)

;Validate files and age of lists

;Scoff

_scoffcheck()

If NOT @error Then

_scoff()

$i=$i+1

$list[$i] = "Scoff law hotlist"

ProgressSet(20)

EndIf

;PSP

_alprcheck()

If NOT @error Then

_psp()

$i=$i+1

$list[$i] = "PSP hotlist"

ProgressSet(30)

EndIf

SetError(0)

;If files validate go

If NOT @error Then

;Transfer CID

_cid()

$i=$i+1

$list[$i] = "CID hotlist"

ProgressSet(40)

If NOT @error Then

;Validate files based on size. DELETED 9/29/08 and incorperated into individual fuctions.

;_transcheck()

ProgressSet(60)

If NOT @error Then

;Data Merge

_Datamerge()

ProgressSet(80)

EndIf

Endif

;Else error out catch all

Else

MsgBox(16,"LCPD LPR", "An error has been generated. Please ensure you are connected to the network and try again. If the problem persists call ME.")

Exit

EndIf

;Display results

$total = _FileCountLines("C:\Datamerge\merged.text")-3

ProgressOff()

MsgBox(0, "Results", "The LPR system has been updated with the following lists: " & $list[0] & ", " & $list[1] & ", " & $list[2] & ". With an estimated " & $total & " entries imported.")

Exit

The array isn't touched in the functions and I'm going to assume this is the only part of the code needed...edited for details of course :-P The only fuction of the array is to record which of the three list successfully updated and then list them...I'm open to other ways of doing that too... I'm still mad my computer runs is fine...


"Could be worse. Could be raining."

Share this post


Link to post
Share on other sites



Its hard to tell without the full code. Are you sure that $list is your ONLY array variable? Keep in mind that UDFs use array variables as well.

Share this post


Link to post
Share on other sites

I lied....I do have more arrays...I just wasn't paying attention...here is the lpr.au3....most of those is network depend so it's not going to work well anyway.

CODE

;Copy Scoff only

Func _scoff()

Local $file

Local $copy

Local $err

$file = FileExists("\\10.17.8.22\Restricted\LPR\scofflaw.TXT")

If $file = 1 Then

$copy = Filecopy("\\10.17.8.22\Restricted\LPR\scofflaw.TXT", "C:\DataMerge\scofflaw.TXT", 1)

Else

$err = MsgBox(53, "Error", "The file Scofflaw.txt could not be found on the network please ensure you are connected to the network.")

SetError(1)

If $err = 4 Then

$copy

Else

Exit

Endif

EndIf

If NOT @Error Then

$scoffloc = FileGetSize("C:\DataMerge\scofflaw.txt")

$scoffser = FileGetSize("\\10.17.8.22\Restricted\LPR\scofflaw.txt")

If $scoffloc = $scoffser Then

;Works

Else

SetError(1)

EndIf

Else

EndIf

EndFunc

;Copy PSP

Func _PSP()

Local $file

Local $copy

Local $err

$file = FileExists("\\10.17.8.22\Restricted\LPR\ALPR.TXT")

If $file = 1 Then

$copy = Filecopy("\\10.17.8.22\Restricted\LPR\ALPR.TXT", "C:\DataMerge\ALRP.TXT", 1)

Else

$err = MsgBox(53, "Error", "The file ALRP.txt could not be found on the network please ensure you are connected to the network.")

SetError(1)

If $err = 4 Then

$copy

Else

Exit

Endif

EndIf

If NOT @Error Then

$psploc = FileGetSize("C:\DataMerge\alpr.txt")

$pspser = FileGetSize("\\10.17.8.22\Restricted\LPR\alpr.txt")

If $psploc = $pspser Then

;Works

Else

SetError(1)

EndIf

Else

EndIf

EndFunc

;Copy CID

Func _CID()

Local $file

Local $copy

Local $err

$file = FileExists("\\10.17.8.22\Restricted\LPR\cidhot.TXT")

If $file = 1 Then

$copy = Filecopy("\\10.17.8.22\Restricted\LPR\cidhot.TXT", "C:\DataMerge\cidhot.TXT", 1)

Else

$err = MsgBox(53, "Error", "The file cidhot.txt could not be found on the network please ensure you are connected to the network.")

SetError(1)

If $err = 4 Then

$copy

Else

Exit

Endif

EndIf

If NOT @Error Then

$CIDloc = FileGetSize("C:\DataMerge\cidhot.txt")

$CIDser = FileGetSize("\\10.17.8.22\Restricted\LPR\cidhot.txt")

If $CIDloc = $CIDser Then

;Works

Else

SetError(1)

EndIf

Else

EndIf

EndFunc

;Run the Datamerge program

Func _DataMerge()

Run("R:\LPR\Batch Files\datamerge.bat", "", @SW_HIDE)

EndFunc

;Validates the age of the ALPR file

Func _alprcheck()

$alpr = FileGetTime("\\10.17.8.22\restricted\lpr\alpr.txt", 0)

$created = $alpr[2]

$createy = $alpr[0]

$createm = $alpr[1]

$date = FileGetTime("plateallvalid.au3",2) ;Cheating, grab current date from the file that called this function

$accessedd = $date[2]

$accessedy = $date[0]

$accessedm = $date[1]

$create = $createm & "/" & $created & "/" & $createy

$ac = $accessedm & "/" & $accessedd & "/" & $accessedy

$outdated = $accessedd - $created ;day minus day

If Not @error Then

If $create = $date Then

; MsgBox(0, "LCPD LPR", "PSP Hotlist is up to date")

ElseIf $outdated < 3 Then

MsgBox(64, "Warning", "PSP hotlist is over 2 days old. Please ensure correctness of the data before taking action against a vehicle.")

Else

MsgBox(0, "LCPD LPR", "PSP Hotlist is " & $outdated & " days old and will not be added to the LPR system.")

SetError(1)

Endif

EndIf

EndFunc

;Validates the age of the scoff File

Func _scoffcheck()

$sc = FileGetTime("\\10.17.8.22\restricted\lpr\scofflaw.txt", 0)

$created = $sc[2]

$createy = $sc[0]

$createm = $sc[1]

$date = FileGetTime("plateallvalid.au3",2) ;Cheating, grab current date from the file that called this function

$accessedd = $date[2]

$accessedy = $date[0]

$accessedm = $date[1]

$create = $createm & "/" & $created & "/" & $createy

$ac = $accessedm & "/" & $accessedd & "/" & $accessedy

$outdated = $accessedd - $created ;day minus day

If Not @error Then

If $ac = $create Then

;MsgBox(0, "LCPD LPR", "Scoff Hotlist is up to date")

ElseIf $outdated < 3 Then

MsgBox(64, "Warning", "Scofflaw hotlist is over 2 days old. Please ensure correctness of the data before taking action against a vehicle.")

Else

MsgBox(0, "LCPD LPR", "Scofflaw Hotlist is " & $outdated & " days old and will not be added to the LPR system.")

SetError(1)

EndIf

EndIf

EndFunc

#cs -- Validates transfer of files. FUNCTION NO LONGER CALLED OR NEEDED. Intergrated into individual copy commands 9/29/08

func _transcheck()

$psploc = FileGetSize("C:\DataMerge\ALRP.TXT")

$cidloc = FileGetSize("C:\DataMerge\cidhot.txt")

$scoffloc = FileGetSize("C:\DataMerge\scofflaw.txt")

$pspser = FileGetSize("\\10.17.8.22\Restricted\LPR\ALPR.TXT")

$cidser = FileGetSize("\\10.17.8.22\Restricted\LPR\cidhot.txt")

$scoffser = FileGetSize("\\10.17.8.22\Restricted\LPR\scofflaw.txt")

If $psploc = $pspser AND $cidloc = $cidser AND $scoffloc = $scoffser Then

;MsgBox(0, "LCPD LRP", "All hotlists successfully updated")

Else

MsgBox(0, "LCPD LRP", "One or more hotlists did not transfer correctly or was outdated. Please check the results at the end of the program for included lists.")

EndIf

EndFunc

#ce


"Could be worse. Could be raining."

Share this post


Link to post
Share on other sites

The only thing I can see is that you're not checking for errors on any of your FileGetTime calls. Since you're using UNC paths, are you sure that the problematic computer is authenticated for access to that share? The FileGetTime calls should be error checked regardless to ensure that an array was returned.

Share this post


Link to post
Share on other sites

All computers are problematic. If I put the file on the server and run it from my desktop it errors. But if I run it from my desktop is works fine. I'd understand the access issues if I could only run it from my computer but I can't run it non-locally.

If I do a display on the FileGetTime (msgbox) I get accurate numbers back sooo....who knows....how you would error check that?

I might have to just figured out a way to document lists.

Thanks though.


"Could be worse. Could be raining."

Share this post


Link to post
Share on other sites

Just check the @error value. Something like:

Func _alprcheck()
    $alpr = FileGetTime("\\10.17.8.22\restricted\lpr\alpr.txt", 0)
    If @error Then
        MsgBox(0, "Error", "Could not retrieve file time for: \\10.17.8.22\restricted\lpr\alpr.txt")
        Return
    Else
        $created = $alpr[2]
        $createy = $alpr[0]
        $createm = $alpr[1]
    EndIf

    $date = FileGetTime("plateallvalid.au3", 2) ;Cheating, grab current date from the file that called this function
    If @error Then
        MsgBox(0, "Error", "Could not retrieve file time for: plateallvalid.au3")
        Return
    Else
        $accessedd = $date[2]
        $accessedy = $date[0]
        $accessedm = $date[1]
    EndIf

    $create = $createm & "/" & $created & "/" & $createy
    $ac = $accessedm & "/" & $accessedd & "/" & $accessedy

    $outdated = $accessedd - $created ;day minus day

    If Not @error Then
        If $create = $date Then
            ; MsgBox(0, "LCPD LPR", "PSP Hotlist is up to date")
        ElseIf $outdated < 3 Then
            MsgBox(64, "Warning", "PSP hotlist is over 2 days old. Please ensure correctness of the data before taking action against a vehicle.")
        Else
            MsgBox(0, "LCPD LPR", "PSP Hotlist is " & $outdated & " days old and will not be added to the LPR system.")
            SetError(1)
        EndIf
    EndIf
EndFunc   ;==>_alprcheck

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I should stop over thinking those error checks....right thanks! I was like...what do I compare them against...I'll post an update tomorrow when I'm back to caring about work :-P

EDIT: Your right! Both return array errors on the FileGetTime...time to find a new what to validate times....it also kicks out another array error but I'm sure its all related...THANKS!

Edited by Imppilot

"Could be worse. Could be raining."

Share this post


Link to post
Share on other sites

Ok so...I understand where the errors are coming from but...I don't know why it.......GD IT!

I'm not declaring full paths.......NOPE...that didn't fix it :-P

Ok so I'm confused on why the program compiles correctly and runs on my local machine....but if I put it on the server...it errors...I'm the one running the script so the access should be the same...or I'd just blame windows share violation.


"Could be worse. Could be raining."

Share this post


Link to post
Share on other sites

Got it..the getfilesize was looking for .au3 which wasn't what it needed...it needed too look at .exe.....always simple stuff.

Now...to try and figure out how to mark this as solved again.


"Could be worse. Could be raining."

Share this post


Link to post
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
Sign in to follow this  
Followers 0