Jump to content

Recommended Posts

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 post
Share on other sites
Posted (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 by Phaser
Link to post
Share on other sites

You are not giving much detail to say something usefull

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

 

Link to post
Share on other sites

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

Link to post
Share on other sites
  • 2 weeks later...

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 post
Share on other sites
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.

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...