AutoHotkey Community

It is currently May 27th, 2012, 12:44 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 21 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: March 21st, 2010, 3:27 pm 
jaco0646 sorry for the delay in replying.

Thanks for this.

Couple of questions.
Is the edit button needed, when you can click on the individual entry ?

I take the update button is no longer needed ?

Thanks again :) :D


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 21st, 2010, 3:29 pm 
Just a quick though, when this was writing to a csv I was looping thought it like:

Code:
   search := findit
   Loop, Read, test.txt
   {
         StringSplit, item, A_LoopReadLine, `,, `r`n
   If ( item1 = search )
      {
      BLAH BLAH BLAH
      Break
   }
   }


How do I do that with an ini, or can this be changed back to a txt/csv ?

Thanks for you help :)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 21st, 2010, 8:32 pm 
jaco0646 - Taking some ideas from your code, I've amended mine and have this working with the csv.

The GUI ID's (numbers) are due to this being a part of a tabbed window.
Code:
#SingleInstance force
   F1=numbermatch.txt
   TestString = 123456,TEST MESSAGE`n
   IfNotExist, %F1%
     FileAppend,%TestString%, %F1%
   Loop,Read,%F1%
     {
       Line%A_Index% := A_LoopReadLine
       Line0 = %A_Index%
     }
   Gui, Add, ListView,grid r15 w320 -Multi -LV0x10 altsubmit vMyListView gMyListView, Name|Email|WWW|Color|ID
   Gui, Add, Button, x25 y275, Add
   Gui, Add, Button, x159 y275 gDELETE, Delete
   Gui, Add, Button, x299 y275, Update
   
   Gui, Show, ,Number Match
   GoSub,FILLLIST
   return
   Gui, Show, Center w365 h310, Options
   
   
FILLLIST:
  LV_Delete()
  Loop, %Line0%
    {   
      StringSplit, Array, Line%A_Index%, `,
      LV_Add("",Array1,Array2,Array3,Array4,A_Index)
    }
  LV_ModifyCol(1,"75")
  LV_ModifyCol(2,"130")
  LV_ModifyCol(3,"AutoHdr")
  LV_ModifyCol(4,"55")
  LV_ModifyCol(5,"0 Integer")
return

MyListView:
  if A_GuiEvent = DoubleClick
    {
      RowNumber := LV_GetNext(0)
      if not RowNumber
          return
      Loop, 5
          LV_GetText(A3%A_Index%, RowNumber,A_Index)
      editadd = edit
      GoSub,SMGUI
    }
return

SMGUI:
colors = aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|purple|red|silver|teal|white|yellow
LV_GetText(color,RowNumber,4)

     Gui,3:Add,Text, xm Section w80 , Name
     Gui,3:Add,Edit, ys-4 w220  vA41, %A31%
     Gui,3:Add,Text, xm Section w80  , Email
     Gui,3:Add,Edit, ys-4 w220  vA42, %A32%
     Gui,3:Add,Text, xm Section w80  , WWW
     Gui,3:Add,Edit, ys-4 w220 vA43, %A33%
     Gui,3:Add,Text, xm Section w80, Color
     Gui,3:Add, ComboBox, ys-4 vA44 SORT, %colours%
     GuiControl, 3:Text, A44, %Color%
     Gui,3:Add, Button, xm, OK
     Gui,3:Show, , TEST
return
 
3ButtonOK:
3GuiClose:
3GuiEscape:
     Gui,3:Submit
     Gui,3:Destroy
     Gui,1:Default
  if editadd = edit
      Line%A35% := A41 . "," . A42 . "," . A43 . "," . A44
  Else
    {
      Line0++
      Line%Line0% := A41 . "," . A42 . "," . A43 . "," . A44
    }
  GoSub,FILLLIST
return

DELETE:
  RowNumber := LV_GetNext(0)
  if not RowNumber
      Return
  Loop, 5
      LV_GetText(A3%A_Index%, RowNumber,A_Index)
 
  Msgbox,4,, Are you sure to delete ?
  Ifmsgbox, No
      return
 
 
  Loop, % Line0 - A35 + 1
    {
      ID := A_Index + A35 - 1
      IDNext := ID + 1
      Line%ID% := Line%IDNext%
    }
  Line0--
  GoSub,FILLLIST
return

ButtonAdd:
  A31=
  A32=
  A33=
  A34=
  editadd=add
  GoSub,SMGUI
return

ButtonUpdate:
  FileContent =
  Loop, %Line0%
      FileContent := FileContent . Line%A_Index% . "`n"
  FileDelete, %F1%
  FileAppend, %FileContent%, %F1%
  Sleep, 500
  ;reload
  Gui, Destroy


Seems to work OK !


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 21st, 2010, 10:18 pm 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
PaulW wrote:
Is the edit button needed, when you can click on the individual entry ?
Not at all; it's just filling space. :idea: It could be a Search button.

PaulW wrote:
when this was writing to a csv I was looping thought it... How do I do that with an ini
An INI file is still just text so you can loop through it the same way; however, it seems a bit wasteful to loop through a file on disk when the data is already in memory (i.e. the ListView).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 22nd, 2010, 5:07 pm 
Quote:
An INI file is still just text so you can loop through it the same way; however, it seems a bit wasteful to loop through a file on disk when the data is already in memory (i.e. the ListView).


Thanks again :)
How would I loop through the listview.. based on my last it of code ??

Cheers


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 22nd, 2010, 8:08 pm 
Offline

Joined: October 15th, 2007, 3:10 pm
Posts: 790
Location: England
Code:
Loop % LV_GetCount() ; loop through every row
{
   LV_GetText( Name, A_Index, 1 ) ; get each of the 5 fields for each row
   LV_GetText( Email, A_Index, 2 )
   LV_GetText( WWW, A_Index, 3 )
   LV_GetText( Color, A_Index, 4 )
   LV_GetText( ID, A_Index, 5 )

  MsgBox, Row %A_Index% is:`n`n%Name% %Email% %WWW% %Color% %ID%
}


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 21 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: chaosad, jrav, MSN [Bot] and 24 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