Jump to content

Script only runs script for first 100 Elements in ARRAY


Recommended Posts

Good Morning,  I have yet again rearranged my script and I am now using an array to populate variables which is a blessing and makes life so much better.  This issue now lies in the type of processing I do and how my script reacts to the array I have setup. Some background,  I have a script that opens and manipulates spreadshseets manually, 

1. Set my Array and do a for next loop
2. Open a spreadsheet, maximize it, move it to a Monitor 1 and It opens to the correctly highlighted cell
3. Open a second spreadsheet, maximize it, move it to monitor 2, and it also opens to the correctly highlighted cell
4. I activate spreadhseet on monitor 1 copy some data
5. activate spreadsheet on monitor 2 paste the data, 
6. save the spreadsheet on monitor 2 and close it
7. close the spreadsheet on monitor 1.
8. look at the saved file for a specific string,  if its there copy that file to a different place
NEXT LOOP

That works perfectly.  I have 147 items in my array and they all generate a file accordingly with no errors,  3 straight runs without issue.   Its not very time efficient and I have been looking into better ways to manipulate the Spreadsheets and found  #include <Excel.au3>.  With that little gem, I am able to run thru the spreadsheets very quickly.  Old way,  14 seconds per item,  with excel.au3,  1 second per item. 

Now, I say all of that to say this,  when I use excel.au3 and run my script,  when it hits the 100th item in the array, it exits.  The script ends.  No error,  no hung spreadsheets, it just exits like its finished.   It did it 4 times straight when tested. 

I went as far as to remove the major code and just step thru the array and splashtext a message that simply counts thru and it ran all the way up to 147.    So I don't know what is happening.

I just took the array and split it into 3 different arrays and with 50, 50 and 48 elements respective and as soon as the last item of the 2nd array finished the script stopped again. AT 100...

Very Strange and I cannot find any logical reason OR any identified limitations on the number or elements in an array when using excel.au3.

 

 

 

 

 

 

 

Link to comment
Share on other sites

:) yes
 

Now, I say all of that to say this,  when I use excel.au3 and run my script,  when it hits the 100th item in the array, it exits.  The script ends.  No error,  no hung spreadsheets, it just exits like its finished.   It did it 4 times straight when tested.

Why  did it exit at the 100th item?     

Edited by HTRN
Link to comment
Share on other sites

Please post your code :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • Developers

Guys, why are you ruining my "chess" game?  my next move ... ;) 

@HTRN, I am pretty sure Line 103 is coded wrong don't you think?

Jos

Edited by Jos

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

Link to comment
Share on other sites

Thanks to everyone for chiming in.   I am developing with a friend who doesn't want the "CODE" public  BUT!!. with the array posted below,  imagine instead of just splashing a text message, I was doing some excel copying and pasting looping thru the same code for 148 elements.  why does it loop thru perfectly as posted below, but dies every time on  ogen, the last element in the 4th line of tickers when I am doing more complex processing between the <for next>?

Am I hitting some limitation I don't know about? 

 

;Setup the ticker array
    $sTkr =  'ABIL,ABIO,ACHV,ADIL,ADMA,AETI,AEZS,AKER,AKTX,ALDX,ALQA,AMRS,AMTX,ANY,APHA,ARCI,ASNA,ASNS,ATAI,ATOS,AVCO,AVEO,AWSM,AXGT,AXSM,' ;25 count
    $sTkr &= 'BIOC,BKS,BLIN,BMMJ,BOXL,BPTH,BURG,CAPR,CCCL,CEI,CIFS,CLDC,CLDX,CLRO,CODX,COTY,CPRX,CUI,DARE,DBD,DCIX,DFFN,DSS,EARS,EGAN,' ;25 count
    $sTkr &= 'ELTK,ENSV,EPZM,FBIO,FCSC,FET,FFHL,FIT,FLXN,FTFT,FTK,FTR,GENE,GEVO,GLBS,GME,GOGO,GSM,GTXI,HMNY,HSGX,IDRA,IGC,INNT,INPX,' ;25 count
    $sTkr &= 'JAGX,JMU,JNUG,KNDI,KTOV,LPCN,MARA,MAXR,MBIO,MBOT,MBRX,MDWD,MLNT,MRIN,MTFB,MTP,MTSL,MXC,NBEV,NK,NOV,NVAX,NVLN,OCX,OGEN,' ;25 count
    $sTkr &= 'OPTT,OVID,OXY,PDSB,PHUN,PLAG,PRPO,PTI,PULM,RBZ,RENN,REPH,RHE,RIOT,RKDA,RNN,SAEX,SCYX,SEEL,SFET,SGYP,SKYS,SLNO,SNOA,SOLO,' ;25 count
    $sTkr &= 'SPEX,SPI,SRNE,STAF,SUNW,SXTC,TBBK,TBLT,TMSR,TNXP,TTNP,UXIN,VTL,VTVT,VVPR,VXRT,WATT,WKHS,WORX,YRIV,ZKIN,ZSAN,ZYNE'  ;23 count
    Global $Tkr = StringSplit($sTkr, ",", 2)


    for $x = 0 to 147
        splashtexton("TICKER",$Tkr[$x]&" "&$x,400,400,1000,200)
        sleep(200)
next

 

 

 

 

 

 

 

Edited by HTRN
Link to comment
Share on other sites

Limits on arrays and string lengths far exceed your examples. You need to provide us an example script the reproduces your issue or we can't help.

Providing us a script that functions won't help us to help you

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

45 minutes ago, HTRN said:

I am developing with a friend who doesn't want the "CODE" public 

Then why bothering asking for help with it? We can't help you fix something if we don't know what that something includes.

Are you by any chance deleting elements of the array in a loop? We don't know because there's nothing to go on.

Is the script silently crashing? No idea, no code.

See where we're coming from?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I know, I know....   Sorry for the "cloak and dagger."  Thank you for verifying that my array comes no where NEAR limitations.  I wish I could just post the whole script and let you have at it but right now that is not an option.  

I promise in the future if I have a question,  I will endeavor to provide all questionable code and current insights but for right now I will just have to break this down to smaller chunks and process it 50 elements at a time in 3 separate scripts.   IF I ever work out a reason I will be sure to post. 

Again,  to all of you,  thank you for this form and the insights that bridge the gap in education between beginner, intermediate and expert autoit scriptors...

 


 

 

 

 

 

 

 

Link to comment
Share on other sites

  • Moderators

Just an FYI, it isn't as if people can't guess you're working on a (rudimentary, it seems) stock checker. Nothing that has not been done before, and certainly nothing that needs the attempt at secrecy, so long as you and your friend have already read through the forum rules.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

"C:\Program Files (x86)\AutoIt3\Include\Excel.au3" (227) : ==> Variable must be of type "Object".:
$oExcel.Windows($oWorkbook.Name).Visible = $bVisible
$oExcel.Windows($oWorkbook.Name)^ ERROR
->08:18:12 AutoIt3.exe ended.rc:1
+>08:18:12 AutoIt3Wrapper Finished.
>Exit code: 1    Time: 123.1

Above is the error I get around the 97th to 100 loop thru.  It looks like there's something breaking in the Excel script. 

I excluded the whole row of the array that includes the tickers  that the loop fails on so I eliminated the possibility of a bad invisible character.   Also as I stated earlier,  I can break the array down to 3 different arrays, cut and paste accordingly 50 elements  in the first and second, 23 in the third  run the script 3 times using the smaller arrays and it completes perfectly, every time.   

below is my loop. and I use the two includes at the top of my script. 
#include <Excel.au3>
#include <Date.au3>

for $x = 0 to 147 step 1    ;Start Array Loop
    splashtexton("Day_Tickers",$Tkr[$x]&" "&$x+1 & "-" & _NowTime(),200,50,3600,0)
    if stringinstr(FileReadline($csv_put&$Tkr[$x]&".csv",1),"timestamp") then   ;Check for good file download
;******************************************************************
;Open EXCEL Spreadsheets and cut and paste amd Save
    Global $EO= _Excel_Open()
    GLobal $WB1= _Excel_BookOpen($EO , $CSV_TEMPLATE ,True)
    Global $WB2= _Excel_BookOpen($EO, $csv_put &$Tkr[$x]&".csv",TRUE)
    Global $WB3= $CSV_SaveAs & $Tkr[$x]
    local $oRange = $WB2.ActiveSheet.Range("A1:F7")
    _excel_rangeCopyPaste($WB1.ActiveSheet, $oRange , "A1")
    _Excel_BookClose($WB2)
    _Excel_BookSaveAs($WB1,$WB3,$xlCSV, True)
    _Excel_BookClose($WB1)
    if stringinstr(FileReadline($CSV_SaveAs&$Tkr[$x]&".csv",2),"HIT") then  ;Generate the HIT Files
    FileCopy($CSV_SaveAs&$Tkr[$x]&".csv", $Hits,1)                          ;Generate the HIT Files
    else
    endIF
;******************************************************************
    Else
    FileWrite($No_Ticker&$Tkr[$x]&$NoTkr_Suffix," ")
    EndIf
    Next
    processclose("Excel.exe")
    EXIT


 

 

Edited by HTRN
Link to comment
Share on other sites

What version of AutoIt and the Excel UDFs are you using? I don't have that line in my copy of the Excel.au3 file.

Quote

The script ends.  No error,  no hung spreadsheets, it just exits like its finished.   It did it 4 times straight when tested. 

BTW, I thought it ended with no errors? 

Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

This is my right of passage.   I was not "Seeing" the error because I had been squeezing the log window down to a single line and all I saw was 

+>09:09:28 AutoIt3Wrapper Finished.

Once I saw the error and posted it I also googled it and guess what.. 

 

DOH!!!  Two little lines.

 Local $oWindow = $oExcel.Windows($oWorkbook.Name) ; <== Modified
    If IsObj($oWindow) Then $oWindow.Visible = $bVisible ; <== Modified

Made the update to excel.au3 and badda bing, we are off to the races.  

Thanks for showing an interest in my plight and thanks to each of you offering your help in  your own special way.. :)

It really did make me dig in want to learn how to perfect my own code..

 

Edited by HTRN
Link to comment
Share on other sites

22 minutes ago, HTRN said:

Made the update to excel.au3 and badda bing, we are off to the races.  

You're using an older version of the Excel.au3 UDF, you should update AutoIt to the latest stable version instead of modifying the one you have.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

OK, if anybody's still looking, The script ran perfectly AFTER I did the 2 line "Fix" for excel.au3 BUT after I upgraded,  After the 2nd run, every time the script hits element 118 in the array, the autoit executable gets a win32 exception.  Even if i run it 64 bit.  I've already turned the debugger off in internet options,  deleted the registry items mentioned on various sites.  I have also changed the DEP setting in computer properties to be for windows programs and services only.    Is there something else I'm missing? 

image.png.dbcb3789db627b99faee42f99ef3991d.pngimage.png.78b1d155051cf13429871f520739342d.png

Link to comment
Share on other sites

I have two comments on what I have seen

  1. Is this the most current version of AutoIt?
  2. Your For loop counter is problematic. Please see the Ubound() function? Hardcoding the For like that to 147 items is bound to cause problems. Punned it :)

 

Skysnake

Why is the snake in the sky?

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