nht3004 1 Posted May 30, 2010 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 variableI'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
Tvern 11 Posted May 30, 2010 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
nht3004 1 Posted May 30, 2010 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
water 2,391 Posted May 30, 2010 (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 May 30, 2010 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - WikiTask Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - WikiTutorials:ADO - Wiki, WebDriver - Wiki  Share this post Link to post Share on other sites
nht3004 1 Posted May 30, 2010 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
Jos 2,211 Posted May 30, 2010 Are you testing the @error for the IniReadSectionNames() function to validate it was successful? SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Share this post Link to post Share on other sites
nht3004 1 Posted May 30, 2010 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
soadmania 0 Posted May 30, 2010 $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
Jos 2,211 Posted May 30, 2010 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. SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Share this post Link to post Share on other sites
nht3004 1 Posted May 30, 2010 (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 May 30, 2010 by nht3004 for(loop=0; loop<infinity; loop++) { alert('I love you'); } Share this post Link to post Share on other sites
soadmania 0 Posted May 30, 2010 Maybe because you dont have the $commandFileName ini Share this post Link to post Share on other sites
Jos 2,211 Posted May 30, 2010 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. SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Share this post Link to post Share on other sites
nht3004 1 Posted May 30, 2010 Maybe because you dont have the $commandFileName ini 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
soadmania 0 Posted May 30, 2010 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
nht3004 1 Posted May 30, 2010 (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.au33052010.txt3052010.html Edited May 30, 2010 by nht3004 for(loop=0; loop<infinity; loop++) { alert('I love you'); } Share this post Link to post Share on other sites
soadmania 0 Posted May 30, 2010 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
nht3004 1 Posted May 30, 2010 (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 May 30, 2010 by nht3004 for(loop=0; loop<infinity; loop++) { alert('I love you'); } Share this post Link to post Share on other sites
soadmania 0 Posted May 30, 2010 (edited) $date=StringSplit(_nowDate(), "."); Not "/" its a "." that could be the problem. Edited May 30, 2010 by soadmania Share this post Link to post Share on other sites
nht3004 1 Posted May 30, 2010 $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
nht3004 1 Posted May 30, 2010 Ok, I see a problem, but I can't fix itNow 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