Sign in to follow this  
Followers 0
nht3004

AutoIt error

35 posts in this topic

I make my program to start when windows start, and I received this:

Line 9224 (File D:\TU\countdown.exe):

Error: Subscript used with non-Array variable

I've compiled my au3 to .exe, and my program has about 200 lines, so line 9224, how can I recognize which line =.='!

When the windows starts, I run the program again, it work, weird :|


for(loop=0; loop<infinity; loop++) { alert('I love you'); }

Share this post


Link to post
Share on other sites



About your error:

Judging from the line number you are feeding a non-array into a function that expects an array

It is most likely caused by a function that returns an array when it runs ok, but a non-array return value if it doesn't. (most likely 0)

If it doesn't succeed and you then try to use the expected array, you get an error, because there is no array. You need to check if the function succeeded before using the results.

About your line number:

When compiling a script all white space and comments are stripped and all included libraries are added to the main script. (this depends on compiling options)

Because of this it is hard to identify the line number of a compiled script without includes and pretty impossible if includes are used.

The solution:

Try to reproduce the error in your uncompiled script to see where the error occurs and add errorchecking.

Share this post


Link to post
Share on other sites

About your error:

Judging from the line number you are feeding a non-array into a function that expects an array

It is most likely caused by a function that returns an array when it runs ok, but a non-array return value if it doesn't. (most likely 0)

If it doesn't succeed and you then try to use the expected array, you get an error, because there is no array. You need to check if the function succeeded before using the results.

About your line number:

When compiling a script all white space and comments are stripped and all included libraries are added to the main script. (this depends on compiling options)

Because of this it is hard to identify the line number of a compiled script without includes and pretty impossible if includes are used.

The solution:

Try to reproduce the error in your uncompiled script to see where the error occurs and add errorchecking.

I have checked

$quan=$filesToDownload[0]

$quan=$filesToDownload^ ERROR

ERROR: Subscript used with non-Array variable

The function that I used to make $filesToDownload an array is IniReadSectionNames() which should return an Array!

Why it works when I start the program again but not the first time on windows startup:|

Please help me!


for(loop=0; loop<infinity; loop++) { alert('I love you'); }

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Maybe the working directory has changed and the ini file no longer can be found.

Check that the function filling the array works correct.

How do you start the script "at windows startup"? Which user runs the script (System Account ...)?

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I can claim that I use the function right, because after I run it again (without any changing, just restart it), it works!

And about the ini file, I have a function to download it and wait until download is finished, inireadsectionnames works!

The thing that make me stuck is that it can not run the first time windows startup but the secondtime :|

Thanks for message back anyway ^^!

But I still need some help


for(loop=0; loop<infinity; loop++) { alert('I love you'); }

Share this post


Link to post
Share on other sites

Are you testing the @error for the IniReadSectionNames() function to validate it was successful?

Yes, like before, it returns 1 when the windows first run and 0 when I restart the program :|

for(loop=0; loop<infinity; loop++) { alert('I love you'); }

Share this post


Link to post
Share on other sites

$filesToDownload = IniReadSection(".ini file", "section name")
If @error<>1 Then
$quan=$filesToDownload[0]

your script

Else
MsgBox(0,"Error", "Ini or Section doesnt exist.")
Endif

make it like that.

Share this post


Link to post
Share on other sites

Yes, like before, it returns 1 when the windows first run and 0 when I restart the program :|

Well, that means that the second time you shouldn't try to "read" the array as there is none.

Show us some code snippet that replicates your issue so we can have a look what might be going wrong.


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Well, that means that the second time you shouldn't try to "read" the array as there is none.

Show us some code snippet that replicates your issue so we can have a look what might be going wrong.

Here you are

$er[1]=Inetget($link,@ScriptDir&"\"&$dataFileName, "", 0);
logs("Received link from sever >> Return code: "&$er[1]);
$commandLink=FileRead(@ScriptDir&"\"&$dataFileName);
logs("Read data from download file");
$er[2]=FileDelete(@ScriptDir&"\"&$dataFileName);
logs("Delete link received from sever >> Return code: "&$er[2]);
$getCommandFile=InetGet($commandLink, $commandFileName, 1, 0);
$filesToDownload=IniReadSectionNames(@ScriptDir&"\"&$commandFileName);
$quan=$filesToDownload[0];
    logs("Analyzing commands");

It works until the 3 last lines!

Edited by nht3004

for(loop=0; loop<infinity; loop++) { alert('I love you'); }

Share this post


Link to post
Share on other sites

Maybe because you dont have the $commandFileName ini :mellow:

Share this post


Link to post
Share on other sites

There is not much that can be done with this snippet.

Would be helpful if you post something that could be run and replicate the error when we run it.


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Maybe because you dont have the $commandFileName ini :mellow:

No no, I have made sure of it! When I start a program again, I can even see the downloaded file, and I have a function logs() to record each step the program run! It downloads the file exactly!

for(loop=0; loop<infinity; loop++) { alert('I love you'); }

Share this post


Link to post
Share on other sites

No no, I have made sure of it! When I start a program again, I can even see the downloaded file, and I have a function logs() to record each step the program run! It downloads the file exactly!

Can you post whole script and inis?

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

Can you post whole script and inis?

Hi, there you are, I use this script to send information to all of my classmates!

I attached 2 logs file that records what happen in the test! The logs contain 2 times of my test, first time windows run, not work, second time after restarting programTruongUpdate.au3, work!

Error in line 100+, around line 117, thanks guys!

Basic.au3

3052010.txt

3052010.html

Edited by nht3004

for(loop=0; loop<infinity; loop++) { alert('I love you'); }

Share this post


Link to post
Share on other sites

That script is a mess. There are variables didnt declared.

C:\Documents and Settings\user\Belgelerim\İndirilenler\Basic.au3(52,36) : WARNING: $currentProgress: possibly used before declaration.
    $aimValue=Execute($currentProgress+
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\user\Belgelerim\İndirilenler\Basic.au3(57,74) : WARNING: $percentPerUp: possibly used before declaration.
            GUICtrlSetData($IDOfProgressBar,Execute($currentProgress+$percentPerUp)
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\user\Belgelerim\İndirilenler\Basic.au3(59,24) : WARNING: $speedOfUpdate: possibly used before declaration.
            Sleep($speedOfUpdate)
            ~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\user\Belgelerim\İndirilenler\Basic.au3(113,73) : WARNING: $Flag_UTF8: possibly used before declaration.
    Return _StringEncrypt(1, BinaryToString(StringToBinary($txt, $Flag_UTF8)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\user\Belgelerim\İndirilenler\Basic.au3(113,86) : WARNING: $Flag_ANSI: possibly used before declaration.
    Return _StringEncrypt(1, BinaryToString(StringToBinary($txt, $Flag_UTF8), $Flag_ANSI)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\user\Belgelerim\İndirilenler\Basic.au3(57,74) : ERROR: $percentPerUp: undeclared global variable.
            GUICtrlSetData($IDOfProgressBar,Execute($currentProgress+$percentPerUp)
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\user\Belgelerim\İndirilenler\Basic.au3(106,28) : ERROR: _ArrayPop(): undefined function.
        $pop=_ArrayPop($arrayName)
        ~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\user\Belgelerim\İndirilenler\Basic.au3(113,100) : ERROR: _StringEncrypt(): undefined function.
    Return _StringEncrypt(1, BinaryToString(StringToBinary($txt, $Flag_UTF8), $Flag_ANSI), $pass, $lvl)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\user\Belgelerim\İndirilenler\Basic.au3 - 3 error(s), 5 warning(s)

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

That script is a mess. There are variables didnt declared.

C:\Documents and Settings\user\Belgelerim\İndirilenler\Basic.au3(52,36) : WARNING: $currentProgress: possibly used before declaration.
    $aimValue=Execute($currentProgress+
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\user\Belgelerim\İndirilenler\Basic.au3(57,74) : WARNING: $percentPerUp: possibly used before declaration.
            GUICtrlSetData($IDOfProgressBar,Execute($currentProgress+$percentPerUp)
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\user\Belgelerim\İndirilenler\Basic.au3(59,24) : WARNING: $speedOfUpdate: possibly used before declaration.
            Sleep($speedOfUpdate)
            ~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\user\Belgelerim\İndirilenler\Basic.au3(113,73) : WARNING: $Flag_UTF8: possibly used before declaration.
    Return _StringEncrypt(1, BinaryToString(StringToBinary($txt, $Flag_UTF8)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\user\Belgelerim\İndirilenler\Basic.au3(113,86) : WARNING: $Flag_ANSI: possibly used before declaration.
    Return _StringEncrypt(1, BinaryToString(StringToBinary($txt, $Flag_UTF8), $Flag_ANSI)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\user\Belgelerim\İndirilenler\Basic.au3(57,74) : ERROR: $percentPerUp: undeclared global variable.
            GUICtrlSetData($IDOfProgressBar,Execute($currentProgress+$percentPerUp)
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\user\Belgelerim\İndirilenler\Basic.au3(106,28) : ERROR: _ArrayPop(): undefined function.
        $pop=_ArrayPop($arrayName)
        ~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\user\Belgelerim\İndirilenler\Basic.au3(113,100) : ERROR: _StringEncrypt(): undefined function.
    Return _StringEncrypt(1, BinaryToString(StringToBinary($txt, $Flag_UTF8), $Flag_ANSI), $pass, $lvl)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\user\Belgelerim\İndirilenler\Basic.au3 - 3 error(s), 5 warning(s)

No, do not look into basic.au3, I only use function alert from them! And for sure, the problem from TruongUpdate.au3 around line 117! Not Basic.au3! Edited by nht3004

for(loop=0; loop<infinity; loop++) { alert('I love you'); }

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

$date=StringSplit(_nowDate(), ".");

Not "/" its a "."

that could be the problem.

Edited by soadmania

Share this post


Link to post
Share on other sites

$date=StringSplit(_nowDate(), ".");

Not "/" its a "."

that could be the problem.

=.='! That is not a problem either, because it used for the file name when write log! And it works!

for(loop=0; loop<infinity; loop++) { alert('I love you'); }

Share this post


Link to post
Share on other sites

Ok, I see a problem, but I can't fix it

Now I make a test file:

InetGet("http://dl.dropbox.com/u/7556171/TU/Command.enht", "Command.enht", "", 0);

And I make that file run on windows startup.

The result is here: It can't download when windows starts it at startup!

Then I run it again, it works!

Bro please help me, I've never met this before:|


for(loop=0; loop<infinity; loop++) { alert('I love you'); }

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