Phaser Posted January 9, 2022 Share Posted January 9, 2022 Hi Guys Been a while, I am using _stringexplode to read a line from a file, this creates the correct array, the last dimension holds a string seperated by a space, so again I explode it into a second array, arraydisplay shows it fine but when I use an If $secondarray[5] it errors with incorrect subscripts etc. If I arraydisplay 1 line above this if statement the array displays correctly? $jaba = GUICtrlRead($hCombo) Do Local $request2 = FileReadLine($request,$iii) Local $aArray2 = _StringExplode($request2, ',') Local $afterfee = $aArray2[6], $prefee = $aArray2[7], $fee = $aArray2[8] Local $aArray22 = _StringExplode($aArray2[9], ' ') ;Out If $aArray2[1] = "Convert" And $aArray2[2] = $jaba Then $beforefee = $beforefee+$prefee $afterfee = $afterfee+$afterfee EndIf ;In If $aArray2[1] = "Convert" And $aArray22[5] = $jaba Then $beforefee = $beforefee+$aArray2[7] $afterfee = $afterfee+$aArray2[6] EndIf $iii = $iii+1; next row in data file Until $iii = 2275 Basically the first if searches 1 array and the second searches 2, it fails on the second part of the second one. Been stairing for hours now, what have I missed? Link to comment Share on other sites More sharing options...
junkew Posted January 9, 2022 Share Posted January 9, 2022 Add a bunch of consolewrite with ubound of the array direcly after splitting FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
Phaser Posted January 9, 2022 Author Share Posted January 9, 2022 (edited) The array is definatly there, the correct ubound and the [5] element will display in a msg box but fails after the if statement. ;_ArrayDisplay($aArray22) ;MsgBox(0,"The Result", "aArray22 5 - " & $aArray22[5]) If $aArray22[5] = $jaba Then $beforefee = $beforefee+$aArray2[7] $afterfee = $afterfee+$aArray2[6] EndIf Edited January 9, 2022 by Phaser Link to comment Share on other sites More sharing options...
junkew Posted January 9, 2022 Share Posted January 9, 2022 You are not giving much detail to say something usefull Try https://www.autoitscript.com/autoit3/docs/functions/FileReadToArray.htm Is it only breaking on a specific line? if so which line Try below and determine iii yourself for reasonable range where you feel it fails Exact message from the error .... if ($iii >= 22) and ($iii < 25) then ;_ArrayDisplay($aArray22) consolewrite(The Result" & "aArray22 5 - " & $aArray22[5] & @CRLF) consolewrite($beforefee+$aArray2[7] &$afterfee+$aArray2[6] & @CRLF) endif If $aArray22[5] = $jaba Then $beforefee = $beforefee+$aArray2[7] $afterfee = $afterfee+$aArray2[6] EndIf FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
Nine Posted January 9, 2022 Share Posted January 9, 2022 If you cannot debug it by yourself, you will need to provide the file ($request) here. And most importantly, make the script runable to us. Then we will be able to efficiently help you, cause right now it is just a guessing game... junkew 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Phaser Posted January 22, 2022 Author Share Posted January 22, 2022 Thanks for the replies guys. OK this is what I am trying to do, I have 2 issues to fix, hopefully I can explain it well enough. Create and run a GUI with a drop down list holding all unique TITLES read from the file - no problem with this Select a TITLE from the list and hit start button to run a function and do something with the lines it reads - no problem with this Issues start here Can the dropdown show the first value on launch? How do I make it stop the function when it reaches the last line it is looking for? currently it keeps looping Ideally, I launch it, it populates, I select which TITLE to look at, it finds 3 lines in the file and displays it to me, it does this all fine. I would like it to stop after the 3 lines and wait for me to select a different TITLE then run again on the next 3 and so on until I close it. I've created a trimmed down version for someone to peruse, thank you in advance. base.csv forum.au3 Link to comment Share on other sites More sharing options...
Nine Posted January 22, 2022 Share Posted January 22, 2022 22 minutes ago, Phaser said: Can the dropdown show the first value on launch? The third parameter of GUICtrlSetData is the default. 23 minutes ago, Phaser said: How do I make it stop the function when it reaches the last line it is looking for? There is a While 1...WEnd that is uselessly infinite. Also your FileClose if wrongly positioned, place it in the killit function instead. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Phaser Posted January 23, 2022 Author Share Posted January 23, 2022 Thanks Nine, all works fine now. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now