JohnBailey Posted January 30, 2007 Author Share Posted January 30, 2007 (edited) Zedna and xcal, thank you both for those leads and explanations. I really don't like not understanding what I'm writing! Now I'm trying to save the change I made to that row. I did the following, but it puts the changed entry at the bottom: If $msg = $btnSaveEdits Then $selected = _GUICtrlListViewGetCurSel($list) _GUICtrlListViewSetItemText($list,$selected,0,GUICtrlRead($editAccountName)) _GUICtrlListViewSetItemText($list,$selected,1,GUICtrlRead($editAccountNumber)) _GUICtrlListViewSetItemText($list,$selected,2,GUICtrlRead($editAccountFile)) _GUICtrlListViewSetItemText($list,$selected,3,GUICtrlRead($editDate)) $file = FileOpen($dataBaseActivity, 1) _ArrayDelete($array, 0) $new = GUICtrlRead($editAccountName) & " * " & GUICtrlRead($editAccountNumber)& " * " & GUICtrlRead($editAccountFile) & " * " & GUICtrlRead($editDate) _ArrayPush($array,$new) $write = _FileWriteFromArray($dataBaseActivity,$array,0) FileClose($file) _GUICtrlListViewDeleteAllItems ($list) GUICtrlSetData($inputAccountName,"") GUICtrlSetData($inputAccountNumber,"") GUICtrlSetData($inputAccountFile,"") list() EndIf Edited January 30, 2007 by JohnBailey A decision is a powerful thing Link to comment Share on other sites More sharing options...
xcal Posted January 30, 2007 Share Posted January 30, 2007 (edited) expandcollapse popup#include <GUIConstants.au3> #include <GUIListView.au3> #include <Array.au3> Global Const $WM_NOTIFY = 0x004E Global Const $NM_FIRST = 0 Global Const $NM_CLICK = ($NM_FIRST - 2) GUICreate('listview', 220, 234) $list = GUICtrlCreateListView('column 1|column 2', 10, 10, 200, 150) GUICtrlCreateListViewItem('column 1 item 1|column 2 item 1', $list) GUICtrlCreateListViewItem('column 1 item 2|column 2 item 2', $list) GUICtrlCreateListViewItem('column 1 item 3|column 2 item 3', $list) _GUICtrlListViewSetColumnWidth($list, 0, 98) _GUICtrlListViewSetColumnWidth($list, 1, 98) $input1 = GUICtrlCreateInput('', 10, 170, 95, 20) $input2 = GUICtrlCreateInput('', 115, 170, 95, 20) $btn1 = GUICtrlCreateButton('Change Selected', 10, 200, 95, 24) $btn2 = GUICtrlCreateButton('Save List', 115, 200, 95, 24) GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events") GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $btn1 $selected = _GUICtrlListViewGetCurSel($list) _GUICtrlListViewSetItemText($list, $selected, 0, GUICtrlRead($input1)) _GUICtrlListViewSetItemText($list, $selected, 1, GUICtrlRead($input2)) Case $btn2 Local $list_count = _GUICtrlListViewGetItemCount($list) Local $array[1] = [$list_count] For $i = 1 To $list_count $replace = StringReplace(_GUICtrlListViewGetItemText($list, $i - 1), '|', ' * ') _ArrayAdd($array, $replace) Next _ArrayDisplay($array, 'Write to a file...') EndSwitch WEnd Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam Local $tagNMHDR, $event $tagNMHDR = DllStructCreate("int;int;int", $lParam);NMHDR (hwndFrom, idFrom, code) If @error Then Return $event = DllStructGetData($tagNMHDR, 3) Select Case $wParam = $list Select Case $event = $NM_CLICK $seltxt = StringSplit(_GUICtrlListViewGetItemText($list), '|') If UBound($seltxt) - 1 = 2 Then GUICtrlSetData($input1, $seltxt[1]) GUICtrlSetData($input2, $seltxt[2]) EndIf EndSelect EndSelect $tagNMHDR = 0 $event = 0 $lParam = 0 Return $GUI_RUNDEFMSG EndFunc Edit - Btw, there are probably people cringing for me handing over direct answers (maybe?) but I'm bored, so I don't mind. Edited January 30, 2007 by xcal How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
JohnBailey Posted January 30, 2007 Author Share Posted January 30, 2007 xcal HAHA Well I really appreciate it because I'm learning a TON! Good call on the StringReplace! Today has actually been so very enlightening in regards to AutoIt and the way my script logic is formed. So, some may cringe at you giving me answers, but rest assured. You're teaching this man to fish. I'm reading the tech docs like crazy because I don't want to just write this stuff out! I want to understand how it works and what I mean by what I write! When I see something new to me, I hit the tech docs and this forum. Thanks again xcal for all your help! A decision is a powerful thing Link to comment Share on other sites More sharing options...
JohnBailey Posted March 7, 2007 Author Share Posted March 7, 2007 (edited) xcal, I know this was awhile ago (thanks again BTW what I learned and what you instructed me specifically to do helped a ton!). I was looking through the script again and I'm fuzzy on a few parts. I've reread and tested several times the manual, yet I'm still in an unclear understanding.1. What does the following mean. I understand that $var = [$numbervar] sets a var to an array, but I don't understand whatLocal $array[1] = [$list_count]means since it's using $array[1]<--- the number and brackets before equaling.2. According to the manual, _ArrayAdd only adds an element to the end of an array. However, the script you showed me actually changes the selected element! Freaking awesome, but how?Again thanks as always!!(this is really just me wanting to really understand this stuff. I'm not having any problems with it. Just curious) Edited March 7, 2007 by JohnBailey A decision is a powerful thing Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 7, 2007 Moderators Share Posted March 7, 2007 It sets the elements of the array. Declare the array: Local $array[1]oÝ÷ ØÚ0Â+auç%j¸§+p{ozÚ%vØ^{^®Þµêí«méÅé^éíw^Æ+5ÂgÌq©è¡j÷½©ny«tz YmëÚçºÚ"µÍØØ[ ÌÍØ^VÌWHHÉÌÍÛÝØÛÝ[ We would have told the interpreter that we have 2 elements in this array ([0] and [1]) And [0] would be empty, and [1] would hold the value contained in $list_count Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
JohnBailey Posted March 7, 2007 Author Share Posted March 7, 2007 freakin' sweet! thanks Smoke_N. Now I'm just trying to understand the _ArrayAdd and it changing the value and not adding an element A decision is a powerful thing Link to comment Share on other sites More sharing options...
JohnBailey Posted March 7, 2007 Author Share Posted March 7, 2007 I think I'm understanding part 2 now. _GUICtrlListViewSetItemText($list, $selected, 0, GUICtrlRead($editAccountName)) _GUICtrlListViewSetItemText($list, $selected, 1, GUICtrlRead($editAccountNumber)) _GUICtrlListViewSetItemText($list, $selected, 2, GUICtrlRead($editAccountFile)) _GUICtrlListViewSetItemText($list, $selected, 3, GUICtrlRead($editDate)) Local $list_count = _GUICtrlListViewGetItemCount($list) Local $array[1] = [$list_count] For $i = 1 To $list_count $replace = StringReplace(_GUICtrlListViewGetItemText($list, $i - 1), '|', ' * ') _ArrayAdd($array, $replace) Next $write = _FileWriteFromArray($dbChoice, $array, 1) The _GUICtrlListViewSetItemText is changing the text of the currently selected listview item and then it's going through the entire listview and saving that back out to the file A decision is a powerful thing 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