AutoHotkey Community

It is currently May 26th, 2012, 11:53 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: November 13th, 2009, 12:02 am 
Offline

Joined: November 10th, 2009, 3:57 am
Posts: 11
I'm trying to write a program to keep track of my finances.

I made a simple GUI with the function to save added data in two different ListViews (one for income, one for outgoing(?))

The following code does not correctly load the data back into the listview.

Code:
ButtonLoadData: ;On button click
Gui, ListView, Inc ;Set focus on ListView with name Inc

getIndex() ;Call getIndex function

Loop, read, %SaveFile% ;loop-read file
{
   If A_Index <= (resultInc // 3) ;if the index is equal or smaller than the total divided by 3
   {
      LV_Add("", A_LoopReadLine, "", "") ;Add line to first column
   }
   Else if A_Index > (resultInc // 3) && A_Index <= (resultInc - (resultInc // 3)) ;if the index is larger than the total divided by 3 and equal to or smaller
                                                                                   ;than the total minus the total divided by 3
   {
      LV_Add("", "", A_LoopReadLine, "") ;Add line to second column
   }
   Else ;if index bigger than all that until eof reached
   {
      LV_Add("", "", "", A_LoopReadLine) ;Add line to third column
   }
}
Return

;------------------------------------------------------------------------

getIndex()
{
Loop, read, %SaveFile% ;loop-read file
   resultInc := A_Index ;save last index number to variable
Return
}


What it does, is it places all data from the file into the second column in my ListView.

Is there an easier way to retrieve data from a file and get them into the right columns ? (maybe saving the data differently in the first place?)
It currently just saves all columns in one row into a textfile. That's why I divide by 3, to split the colums.

Also notice this is just the part for the Income.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 13th, 2009, 2:34 am 
Offline

Joined: November 10th, 2009, 3:57 am
Posts: 11
I made an easier version, but it still gives the same result: (I also changed the way the script saves the data to the file.

Maybe there's a way to save the column data to a text file using tab delimiters? So that it can read from the file using those delimiters?

Code:
ButtonLoadData: ;On button click
Gui, ListView, Inc ;Set focus on ListView with name Inc

Loop, Read, %SaveFile% ;loop-read file
{
   StringSplit, incArray, A_LoopReadLine, `, ;StringSplit into an array
}

countInc = %incArray0% ;Saving the objectcount in the array to a variable

Loop, %countInc% ;looping through the array
{
   resultInc := incArray%A_Index% ;Point current object to a variable
   
   If A_Index <= (countInc // 3) ;Same code as my other solution
   {
      LV_Add("", resultInc, "", "")
   }
   Else if A_Index > (countInc // 3) && A_Index <= (countInc - (countInc // 3))
   {
      LV_Add("", "", resultInc, "")
   }
   Else
   {
      LV_Add("", "", "", resultInc)
   }
}
Return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 13th, 2009, 4:13 am 
Offline

Joined: November 10th, 2009, 3:57 am
Posts: 11
Fixed it !

Code:
Gui, ListView, Inc
Loop, Read, %SaveFileInc%
{
   Loop, parse, A_LoopReadLine, `,
   {
      if A_Index = 1
      {
         LV_Add("", "", "", "")
         LV_Modify(x, "Col1", A_LoopField)
      }
      else if A_Index = 2
      {
         LV_Modify(x, "Col2", A_LoopField)
      }
      else if A_Index = 3
      {
         LV_Modify(x, "Col3", A_LoopField)
         x += 1
      }
   }
}


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], hyper_, Leef_me, patgenn123, Pulover, RaptorX, rbrtryn, tidbit, XstatyK and 21 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group