Sign in to follow this  
Followers 0
deef99

Auto It Error Line -1: What does it mean?

9 posts in this topic

When I run this code with editor, it works fine. When I compile it to an EXE and click it to start, I get this error:

Auto It Error

Line -1

Error: variable must be declared

What is wrong? I am out of vacation next week and I need this working!!! Can someone PLEASE HELP!

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****

#AutoIt3Wrapper_outfile=G:\CallCenter_downloads\tfn_turndown\TFN_Checker.exe

#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include "array.au3"

#include "File.au3"

#include "Date.au3"

#include "String.au3"

$file = ""

$file1 = ""

$dest = "\\ardfiles01\common\CallCenter_downloads\tfn_change.csv"

$final = "\\ardfiles01\common\CallCenter_downloads\TFN Archive\"

$logfile = ""

$CountLines = 0

If ProcessExists("asa.exe") Then

ProcessClose("asa.exe")

EndIf

Run("C:\Program Files\Avaya\Site Administration\bin\ASA.exe")

Sleep(3000)

Send("^g")

Sleep(3000)

;this will keep program running and checking for another file...

While 1

;look for first occurance of a file

$search = FileFindFirstFile("\\ardfiles01\common\CallCenter_downloads\tfn_turndown\*.csv")

While 1

;look for additional files

$file1 = FileFindNextFile($search)

If @error Then ExitLoop

;ConsoleWrite("Doing stuff to " & " - " & $file1 & @CRLF)

FileCopy("\\ardfiles01\common\CallCenter_downloads\tfn_turndown\" & $file1, $dest, 1)

FileDelete("\\ardfiles01\common\CallCenter_downloads\tfn_turndown\" & $file1)

;set the MM_YYYY for log file

$tday = @MON & "_" & @YEAR

;open log file LogMM_DD.txt

$logfile = FileOpen("\\ardfiles01\common\CallCenter_downloads\tfn_turndown\TFN_Log" & $tday & ".txt", 1)

;get the current hour and min

$tCur = @MON & "/" & @MDAY & "," & @HOUR & ":" & @MIN & " - "

$file = FileOpen("\\ardfiles01\common\CallCenter_downloads\tfn_change.csv", 0)

$iCount = 0 ; <<<<<<<<<<<<<<<<< check line

; Read in lines of text until the EOF is reached

While 1

$line = FileReadLine($file)

If @error = -1 Then ExitLoop

$iCount += 1 ; <<<<<<<<<<<<<<<<< check line

;ConsoleWrite("Doing Stuff to " & " - " & $file1 & " - " & $iCount & @CRLF)

FileWrite($logfile, $tCur & $line & @CRLF)

$array = StringSplit($line, ",")

If Not IsArray($array) Then ContinueLoop ; check if it is an array!

If UBound($array) < 5 Then ContinueLoop ; check it has enough elements!

Select

Case $array[4] = "U"

$vec = 200

Case $array[4] = "D"

$vec = 61

EndSelect

;set up correct Switch code for Product

Select

Case $array[3] = "gr_gt"

$n = "IB " & $array[1] & " GR GT"

Case $array[3] = "grc3"

$n = "IB " & $array[1] & " GR MA"

Case Else

$n = $array[3] & " is not an Active Proj Code for " & $array[1]

EndSelect

;Process this vdn now with ASA

If StringLeft($n, 2) <> "IB" Then

FileWrite($logfile, $tCur & $n & @CRLF)

Else

$f = "ch vdn " & $array[2]

WinActivate("Avaya Site Administration")

Sleep(1000)

Send($f & "{ENTER}")

Sleep(500)

Send($n & "{ENTER}")

Sleep(500)

Send($vec & "{F3}")

Sleep(1000)

Send("{ESC}")

FileWrite($logfile, $tCur & $f & " as " & $n & " to Vector " & $vec & @CRLF)

Sleep(1000)

EndIf

WEnd

FileClose($file)

FileCopy("\\ardfiles01\common\CallCenter_downloads\tfn_change.csv", "\\ardfiles01\common\CallCenter_downloads\TFN Archive\TFN_DONE" & @MDAY & @MSEC & ".csv", 1)

FileClose($logfile)

Sleep(5000)

WEnd

FileClose($search)

WEnd

Share this post


Link to post
Share on other sites



Error with line -1 happens when there is an error in your script when it is run as an exe.

If you run it as a script with exactly the same conditions you will almost certainly get an error but you will get a lot more information about the cause.

You say that it doesn't give an error unless it's compiled but I really doubt that you are running it in the same way.

There are certainly things you should be doing in your script to avoid problems. For example, you only set the variable $vec under certain conditions, but later in your script you use $vec without considering that it might not exist.

Better to declare all variables and better still to use

Opt("MustDeclareVars",1)


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

I added to the begin on the script:

Opt("MustDeclareVars",1)

dim $array, $iCount, $line,$n,$f,$file,$file1,$dest,$vec,$tCur,$tday,$search,$final,$logfile,$CountLines

Compiled it...and it still gives me the same error... {sigh}

Error with line -1 happens when there is an error in your script when it is run as an exe.

If you run it as a script with exactly the same conditions you will almost certainly get an error but you will get a lot more information about the cause.

You say that it doesn't give an error unless it's compiled but I really doubt that you are running it in the same way.

There are certainly things you should be doing in your script to avoid problems. For example, you only set the variable $vec under certain conditions, but later in your script you use $vec without considering that it might not exist.

Better to declare all variables and better still to use

Opt("MustDeclareVars",1)

Share this post


Link to post
Share on other sites

Just run the .au3 file instead of compiled EXE and you will see the line number where the error is.

Share this post


Link to post
Share on other sites

It does not give me any error when I just run the script using Auto It, Tools, GO

...this is so frustating!

Just run the .au3 file instead of compiled EXE and you will see the line number where the error is.

Share this post


Link to post
Share on other sites

Quickest debuging trick I can think to try: throw a few MsgBox's in there, with gradual increasing numbers as the text in them, just to see how far your script gets before it crashes out. Then, when you find that, keep working down till you find the line causing the error.

Really, is debuging scripts that different from writing them?

Share this post


Link to post
Share on other sites

I've done that too...but the script gives the error BEFORE I get to a msgbox!

Quickest debuging trick I can think to try: throw a few MsgBox's in there, with gradual increasing numbers as the text in them, just to see how far your script gets before it crashes out. Then, when you find that, keep working down till you find the line causing the error.

Really, is debuging scripts that different from writing them?

Share this post


Link to post
Share on other sites

I've done that too...but the script gives the error BEFORE I get to a msgbox!

Even if you put a msgbox at the very first line?

Try before your includes as well because you are not using the files supplied with AutoIt possibly, at least you are not using the files in the includes folder unless your script is also in the includes folder.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

I know this kind of situation. Usually you just have to keep adding msgboxes until you get to the problem which can be in some included file as well, don't forget this.

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