metis Posted April 8, 2011 Share Posted April 8, 2011 (edited) Hi. I need code which will delete data of(in) list. Me code : expandcollapse popup;GUI<><><><><><><><><><><><><><><><><><><><><><><><><><><><>\/ $InputLogin2 = GUICtrlCreateInput("", 590, 50, 121, 21) $InputHaslo2 = GUICtrlCreateInput("", 590, 80, 121, 21, $ES_PASSWORD) $Add2 = GUICtrlCreateButton("ADD", 520, 200, 190, 30, $WS_GROUP) $List12 = GUICtrlCreateList("",735, 60, 121, 350) ;END GUI<><><><><><><><><><><><><><>/\ ;- ;- ;- ;READ FILE<><><><><><><><><><><><><><><><><><><><><><><><><><><><>\/ If FileExists(@ScriptDir & "/config2.ini") Then Global $ns = IniRead("config2.ini", "licznik", "t", "") Global $charnames For $a = 1 To $ns - 1 Step +1 ;zapisuje do n-1 dlatego ze przy zapisywaniu licznika dodajemy 1, i po zapisaniu 2 charow licznik wskazuje 3 GUICtrlSetData($List12, IniRead("config2.ini", "Character" & $a, "charnames", "")) Next Else Global $ns = 1 EndIf ;END READ FILE<><><><><><><><><><><><><><>/\ ;- ;- ;- ;WHILE/CASE<><><><><><><><><><><><><><><><><><><><><><><><><><><><>\/ Case $Add2 Global $charnames = InputBox("Podaj Nick", "Podaj nazwę która ma być wyświetlana", "") If @error Then ;jesli klikne cancel to nic nie zrobi ze stringami, zignoruje blad ContinueCase EndIf $e = GUICtrlRead($InputLogin2) $r = GUICtrlRead($InputHaslo2) if $charnames = "" or $e = "" or $r = "" Then MsgBox(0, "Error", "Pola Loginu, Hasła i nazwy nie mogą być puste") Else #comments-start Ten fragment kodu zapisuje, to co odczyta ze wszystkich kontrolek Dodaje wartosc do licznika, ktora pokazuje ilosc postaci jako ze zapis $ns = $ns +1 wystepuje po dodaniu chara, to gdy sa 2 chary, licznik pokazuje 3, dlatego w petlach jest uzywany zapis $ns = $ns -1 ktory pokazuje faktyczna ilosc postaci #comments-end IniWrite("config2.ini", "Character" & $ns, "charnames", $charnames) IniWrite("config2.ini", "Character" & $ns, "log", $e) IniWrite("config2.ini", "Character" & $ns, "has", $r) ;IniWrite("config2.ini", "Character" & $ns, "charno", $ns) ;zapisuje kolejny numer postaci GUICtrlSetData($List12, IniRead("config2.ini", "Character" & $ns, "charnames", "")) $ns = $ns + 1 IniWrite("config2.ini", "licznik", "t", $ns) EndIf Case $List12 For $zmienna12 = 1 To $ns Step +1 ;sprawdza x razy(tyle ile jest charow) co zostalo zaznaczone, jesli zostal zaznaczony dany char, to laduje jego dane ;sprawdza czy zaznaczenie listy jest rowne nazwie postaci If GUICtrlRead($List12) = IniRead("config2.ini", "Character" & $zmienna12, "charnames", "") Then GUICtrlSetData($InputLogin2, IniRead("config2.ini", "Character" & $zmienna12, "log", "")) GUICtrlSetData($InputHaslo2, IniRead("config2.ini", "Character" & $zmienna12, "has", "")) EndIf Next For $zmienna12 = 1 To $ns Step +1 ;sprawdza x razy(tyle ile jest charow) co zostalo zaznaczone, jesli zostal zaznaczony dany char, to laduje jego dane ;sprawdza czy zaznaczenie listy jest rowne nazwie postaci If GUICtrlRead($List12) = IniRead("config2.ini", "Character" & $zmienna12, "charnames", "") Then GUICtrlSetData($InputLogin2, IniRead("config2.ini", "Character" & $zmienna12, "log", "")) GUICtrlSetData($InputHaslo2, IniRead("config2.ini", "Character" & $zmienna12, "has", "")) EndIf Next ;END WHILE/CASE<><><><><><><><><><><><><><>/\ config2.ini [Character1] charnames=NAMES log=LOGIN has=PASSWORD [licznik] t=3 [Character2] charnames=NAMES2 log=LOGIN2 has=PASSWORD2 Edited April 8, 2011 by metis Link to comment Share on other sites More sharing options...
smartee Posted April 8, 2011 Share Posted April 8, 2011 Search for _GUICtrlListBox_DeleteString() in the help file. Link to comment Share on other sites More sharing options...
metis Posted April 8, 2011 Author Share Posted April 8, 2011 Legend = Text << language my point is to properly delete the data in the config2.ini << English 1 I mean so that appropriately he removes data in config2.ini << English 2 mi chodzi o to aby odpowiednio usuwał dane w config2.ini << Poland Link to comment Share on other sites More sharing options...
smartee Posted April 8, 2011 Share Posted April 8, 2011 Have you tried IniDelete()? Link to comment Share on other sites More sharing options...
metis Posted April 9, 2011 Author Share Posted April 9, 2011 As for removing the different data config2.ini, I delete Character3 <EN1 he walks for removing individual data in config2.ini,I want delete Character3,The program must move all charcters and to change "licznik" <EN2 chodzi o usunięcie poszczególnych danych w config2.ini, chcę usunąć Characte3,Program musi przestawić wszystkie charcters i zmienić "" <PL [Character1] charnames=NAMES log=LOGIN has=PASSWORD [licznik] t=5 [Character2] charnames=NAMES2 log=LOGIN2 has=PASSWORD2 [Character3] charnames=NAMES3 log=LOGIN3 has=PASSWORD3 [Character4] charnames=NAMES4 log=LOGIN4 has=PASSWORD4 Link to comment Share on other sites More sharing options...
smartee Posted April 9, 2011 Share Posted April 9, 2011 try this$ini = @ScriptDir & "\config2.ini" IniDelete($ini, "Character3") IniWrite($ini, "licznik", "t", (IniRead($ini, "licznik", "t", 1)) - 1) Link to comment Share on other sites More sharing options...
metis Posted April 9, 2011 Author Share Posted April 9, 2011 Now I have nothing on the list; / if the "licznik " is 5, we have four charnames [1/2/3/4], but if I delete the 3 and presents a "licznik" for less then do not see anything. I need that as I delete "charnames3"is "charnames4" changed to "charnames3" <EN1now I have nothing on the list; / if the "licznik" is 5 these are mums 4 charnames [1 / 2 / 3 / 4] but if I will remove 3 and I will move the "licznik" on less it is then nothing not apparently. He needs that how I will remove "charnames 3" it "charnames 4" changed on "charnames 3" <EN2teraz nie mam nic na liście ;/ jeśli "licznik" jest 5 to mamy 4 charnames [1/2/3/4] ale jeśli usunę 3 i przestawię "licznik" na mniej to wtedy nic nie widać. Potrzebuje że jak usunę "charnames3" to "charnames4" zmieniło się na "charnames3" <PL Link to comment Share on other sites More sharing options...
smartee Posted April 9, 2011 Share Posted April 9, 2011 here you go$ini = @ScriptDir & "\config2.ini" $delete = "Character3" $delete = Number(StringReplace($delete, "Character", "")) IniDelete($ini, "Character" & $delete) For $i = $delete + 1 to (IniRead($ini, "licznik", "t", 1)) IniRenameSection($ini, "Character" & $i, "Character" & $i - 1) Next IniWrite($ini, "licznik", "t", (IniRead($ini, "licznik", "t", 1)) - 1) Link to comment Share on other sites More sharing options...
metis Posted April 9, 2011 Author Share Posted April 9, 2011 Delete is good. I have problem read to me GUI expandcollapse popupCase $dell2 If FileExists(@ScriptDir & "/config2.ini") Then $ans = IniRead("config2.ini", "licznik", "t", "") -1 if $ans <= 0 Then MsgBox(0,"Error", "Brak Danych") If FileExists(@ScriptDir & "/config2.ini") Then FileDelete (@ScriptDir & "\config2.ini") EndIf Else $answer = InputBox("Delete", "Where delete ?", "") if $answer <= $ans and $answer > 0 Then $ini = @ScriptDir & "\config2.ini" $delete = "Character"& $answer $delete = Number(StringReplace($delete, "Character", "")) IniDelete($ini, "Character" & $delete) For $i = $delete + 1 to (IniRead($ini, "licznik", "t", 1)) IniRenameSection($ini, "Character" & $i, "Character" & $i - 1) Next IniWrite($ini, "licznik", "t", (IniRead($ini, "licznik", "t", 1)) - 1) Global $ns4 = IniRead("config2.ini", "licznik", "t", "") MsgBox(0, "",$ns4) For $a4 = 1 To $ns4 - 1 Step +1 ;zapisuje do n-1 dlatego ze przy zapisywaniu licznika dodajemy 1, i po zapisaniu 2 charow licznik wskazuje 3 GUICtrlSetData($List12, IniRead("config2.ini", "Character1", "charnames", "")) Next Else Global $ns4 = 1 EndIf $deltest = (IniRead($ini, "licznik", "t", 1)) if $deltest = 0 or $deltest = 1 Then FileDelete($ini) EndIf Else MsgBox(0, "Error" , "Error NAME") EndIf EndIf Else MsgBox(0, "Error" , "Error Files Config2.ini") EndIf Code not read to gui ;/ Link to comment Share on other sites More sharing options...
smartee Posted April 9, 2011 Share Posted April 9, 2011 here's a way to read it to a gui#include <GUIListBox.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> $ini = @ScriptDir & "\config2.ini" GUICreate("ListBox Display", 400, 296) $hListBox = GUICtrlCreateList("", 2, 2, 396, 296, BitOR($LBS_NOTIFY, $LBS_SORT, $WS_HSCROLL, $WS_VSCROLL)) GUISetState() _GUICtrlListBox_BeginUpdate($hListBox) For $i = 1 To (IniRead($ini, "licznik", "t", 1)) - 1 _GUICtrlListBox_AddString($hListBox, IniRead($ini, "Character" & $i, "charnames", "NotFound")) Next _GUICtrlListBox_UpdateHScroll($hListBox) _GUICtrlListBox_EndUpdate($hListBox) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() Link to comment Share on other sites More sharing options...
metis Posted April 9, 2011 Author Share Posted April 9, 2011 (edited) I did . I want to do that as you type the name (which displays a be a letter) in (inputbox) it is clear to me I did . I want to do that how he will write the name down (which oneself wyświela into the letter) in (inputbox) it is supposed for me to remove Zrobiłem. Chcę zrobić że jak wpisze nazwę(która się wyświela w list) w(inputbox) to ma mi usunąć. CODE : expandcollapse popupCase $dell2 If FileExists(@ScriptDir & "/config2.ini") Then $ans = IniRead("config2.ini", "licznik", "t", "") -1 if $ans <= 0 Then MsgBox(0,"Error", "Empty or Error Files") FileDelete (@ScriptDir & "\config2.ini") Else $answer = InputBox("Delete", "Please number Characters", "") ; i need charnames!!!!!!!!! ; i need charnames!!!!!!!!! if $answer <= $ans and $answer > 0 Then $ini = @ScriptDir & "\config2.ini" $delete = "Character"& $answer $delete = Number(StringReplace($delete, "Character", "")) IniDelete($ini, "Character" & $delete) For $is = $delete + 1 to (IniRead($ini, "licznik", "t", 1)) IniRenameSection($ini, "Character" & $is, "Character" & $is -1) Next IniWrite($ini, "licznik", "t", (IniRead($ini, "licznik", "t", 1)) - 1) GUICtrlSetData($List12, "") $deltest = (IniRead($ini, "licznik", "t", 1)) if $deltest = 0 or $deltest = 1 Then FileDelete($ini) EndIf If FileExists(@ScriptDir & "/config2.ini") Then Global $ns = IniRead("config2.ini", "licznik", "t", "") Global $charnames For $a = 1 To $ns - 1 Step +1 GUICtrlSetData($List12, IniRead("config2.ini", "Character" & $a, "charnames", "")) Next Else Global $ns = 1 EndIf Else MsgBox(0, "Error" , "Error") EndIf EndIf Else MsgBox(0, "Error" , "Error Files Config2.ini") EndIf Edited April 9, 2011 by metis Link to comment Share on other sites More sharing options...
smartee Posted April 10, 2011 Share Posted April 10, 2011 I know you have provided two different translations, however, maybe due to the language barrier, I am having a hard time understanding your question.Perhaps you can try rephrasing it, and/or being more precise, if possible. Thank you. Link to comment Share on other sites More sharing options...
metis Posted April 10, 2011 Author Share Posted April 10, 2011 i need instead of [character > charnames] $delete = "Charnames"& $answer $answer = InputBox("Delete", "Please name Charnames", "") i need next code Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 10, 2011 Moderators Share Posted April 10, 2011 metis,I think this does what you want - as far as I can understand what it is you are trying to do: expandcollapse popup#include <GUIConstantsEx.au3> #include <EditConstants.au3> Global $ns = 0 $hGUI = GUICreate("Test", 500, 500) $InputLogin2 = GUICtrlCreateInput("", 10, 50, 121, 21) $InputHaslo2 = GUICtrlCreateInput("", 10, 80, 121, 21, $ES_PASSWORD) $Add2 = GUICtrlCreateButton("ADD", 10, 200, 190, 30) $Del2 = GUICtrlCreateButton("DEL", 10, 250, 190, 30) $List12 = GUICtrlCreateList("", 200, 60, 121, 350) GUISetState() _ReadFile() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $Del2 $sName = GUICtrlRead($List12) If Not @error Then If MsgBox(4, "Confirm", "Are you sure you want to delete " & $sName) = 6 Then ; read section names $aSectionList = IniReadSectionNames(@ScriptDir & "\config2.ini") ; Delete and rename sections For $i = 1 To $aSectionList[0] ; Go through sections to find the section to delete If IniRead("config2.ini", "Character" & $i, "charnames", "") = $sName Then ; Delete the section IniDelete("config2.ini", "Character" & $i) ; Rename later sections For $j = $i To $aSectionList[0] IniRenameSection("config2.ini", "Character" & $i + 1, "Character" & $i) Next ; Change count $ns -= 1 IniWrite("config2.ini", "licznik", "t", $ns) ; Rewrite list GUICtrlSetData($List12, "") _ReadFile() ExitLoop EndIf Next EndIf EndIf Case $Add2 Global $charnames = InputBox("Please Enter Nickname", "Enter the name to be displayed", "") If Not @error Then $e = GUICtrlRead($InputLogin2) $r = GUICtrlRead($InputHaslo2) If $charnames = "" Or $e = "" Or $r = "" Then MsgBox(0, "Error", "Login, password and name fields can not be empty") Else $ns = $ns + 1 IniWrite("config2.ini", "licznik", "t", $ns) IniWrite("config2.ini", "Character" & $ns, "charnames", $charnames) IniWrite("config2.ini", "Character" & $ns, "log", $e) IniWrite("config2.ini", "Character" & $ns, "has", $r) GUICtrlSetData($List12, $charnames) EndIf EndIf Case $List12 For $zmienna12 = 1 To $ns; Step +1 If GUICtrlRead($List12) = IniRead("config2.ini", "Character" & $zmienna12, "charnames", "") Then GUICtrlSetData($InputLogin2, IniRead("config2.ini", "Character" & $zmienna12, "log", "")) GUICtrlSetData($InputHaslo2, IniRead("config2.ini", "Character" & $zmienna12, "has", "")) EndIf Next EndSwitch WEnd Func _ReadFile() If FileExists(@ScriptDir & "\config2.ini") Then Global $ns = IniRead("config2.ini", "licznik", "t", "") Global $charnames For $a = 1 To $ns GUICtrlSetData($List12, IniRead("config2.ini", "Character" & $a, "charnames", "")) Next Else Global $ns = 0 EndIf EndFuncNote that I have altered the code so that your counter now reads correctly - you no longer have to use counter - 1. If this is not what you are looking for then please find someone whose Engish is good enough to explain what it is you want - Google Translate has got me this far but both it and I have hit our limits. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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