fxg4758 0 Posted July 15, 2011 Share Posted July 15, 2011 Hi all. I made a function to read a txt file and put the the lines in checkbox. But now i need to select which checkbox is checked, open txt file, delete the line with same name and file outside with the same name and delete or hide same checkbox from the gui. And a doubt, i put this function outside the function with the gui. How can i delete the gui without have to declare the global name of the gui. Regards! If Not _FileReadToArray($Test,$aRecords) Then MsgBox(262160,"Error!!", "File not found!") FileChangeDir(@ScriptDir) Return 0 Else For $x = 1 to $aRecords[0] $X_Coord = 32 + (($x - 1) * 32) $Checkbox = GUICtrlCreateCheckbox($aRecords[$x], 32,$X_Coord, 273, 33) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") GUISetState() Next EndIf Link to post Share on other sites
JohnOne 1,626 Posted July 15, 2011 Share Posted July 15, 2011 How can i delete the gui without have to declare the global name of the gui. Regards!Sorry but this part is all I understand of the post. I think you could delete a gui from any function as long as you pass that function the handle of it.Cant see a gui in that code either, sorry. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to post Share on other sites
pieeater 1 Posted July 15, 2011 Share Posted July 15, 2011 (edited) look up the: ControlCommand() GUIDelete() FileRead() StringInStr() FileDelete() FileWrite() ControlHide() ControlShow() functions in the help file to delete the line then write a new line you would have to read the file, find the line you want with an exact match with the stringinstring, make a backup copy(optional), delete the file, write the file without using the line and adding the line into it. you should get arrays from the stringinstr() so all you have to do is: $var = $array[1] & "new line" & @lf & $array[2] im not sure if it would work though, it may pick up the line earlier then when you want it to. Edited July 15, 2011 by pieeater [spoiler]My UDFs: Login UDF[/spoiler] Link to post Share on other sites
fxg4758 0 Posted July 16, 2011 Author Share Posted July 16, 2011 (edited) Thanks pieeater. But now i can´t detect which Checkbox is checked. I try this code, but it will run once and i have to close and open the form again to select another checkbox. And i can´t delete the first checkbox. Thanks! Function to create checkbox: For $x = 1 to $aRecords[0] $X_Coord = 32 + (($x - 1) * 32) $Checkbox = GUICtrlCreateCheckbox($aRecords[$x], 32,$X_Coord, 273, 33) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") GUISetState() Next Function to check state of checkbox above: Func _IsChecked($sTitle, $iCtrlID) Return ControlCommand($sTitle, "", $iCtrlID, "IsChecked") EndFunc Function to select checkbox and delete line from txt file: If _IsChecked(Form1, $Checkbox) Then $j = _FileCountLines("test.txt") For $I = 1 To $j _FileReadToArray("test.txt", $aFile) $iline = _ArraySearch($aFile,_GUICtrlButton_GetText($Checkbox), 1, $aFile[0], 1, 0, 1) _FileWriteToLine("test.txt", $iline, "",1) ControlHide(Form1, "", $Checkbox) Next Else ConsoleWrite(">Check box #" & $Checkbox & " is unchecked" & @CRLF) EndIf Edited July 16, 2011 by fxg4758 Link to post Share on other sites
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