cyberalau3 Posted February 4, 2015 Share Posted February 4, 2015 I know this might be to general of a question but why might GUICtrlCreateList fail? I use it in two different areas of my script and one works just fine all the time and the second fails every time.... Thanks - I'v been fighting this for a few days now. CyberAl Link to comment Share on other sites More sharing options...
MikahS Posted February 4, 2015 Share Posted February 4, 2015 Please, post your script so we can see what you have done. Otherwise, we are stabbing at this in the dark. Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
cyberalau3 Posted February 4, 2015 Author Share Posted February 4, 2015 The script is pretty large (over 3000 lines) Can I do that? It also needs some support files if you actually wanted to run it. Should I try to just create a small example that might demonstrate the problem?? I not even sure if I can duplicate it. Thanks CyberAl Link to comment Share on other sites More sharing options...
MikahS Posted February 4, 2015 Share Posted February 4, 2015 I don't think I'll need to run it, but posting the creation of these lists, what they are used in, and anything that is interacting with them, in a logical manner would greatly help. As, without seeing how you create it or interact with it, we are flying completely blind. Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
cyberalau3 Posted February 4, 2015 Author Share Posted February 4, 2015 ;It's the GUICtrlCreateList in this function that works fine ......................................................... Func Change() Local $file = FileOpen($sConfig, 0) ;Read mode If $file = -1 Then Beep(390, 400) _extmsgbox(48, 0, "Cannot continue " & @ScriptLineNumber, "The " & $sConfig & @CRLF & " did not open properly, Exiting now ...", 0, 20, 400) Exit EndIf FileCopy($sConfig, $sConfigSaved, 1) Global $sSavedSel = GUICtrlRead($FolderList) MsgBox(0,@ScriptLineNumber,$sSavedSel) While 1 If StringLeft(GUICtrlRead($FolderList), 23) = "----Folder Location----" Then Beep(390, 400) _extMsgBox(16, 0, "Error " & @ScriptLineNumber, "You have selected a invalid line." & @CRLF & "Your selection is invalid, try again...", 0, 20, 400) Return EndIf Local $newsel = FileSelectFolder("Choose a folder to add to BACKUP LIST.", "C:", 2) If @error = 1 Then $newsel = $sSavedSel Return ; I think 'cancel' was chosen EndIf Local $NewConfigLine = StringLeft($sSavedSel, 3) & $newsel ;"09 #C:Als Scans" Local $newConfigLineNum = Number(StringLeft($NewConfigLine, 2)) MsgBox(0,@ScriptLineNumber,$NewConfigLine & " " & $newConfigLineNum) ExitLoop WEnd FileClose($file) ;Config.txt live file Local $ConfigFileSaved = FileOpen($sConfigSaved, 0) ;Read mode for configSaved.txt If @error = -1 Then Beep(390, 400) _extMsgBox(48, 0, "Error " & @ScriptLineNumber, "The " & $sConfigSaved & " file did not open properly" & @CRLF & _ "Cannot continue, exiting program", 0, 20, 400) Exit EndIf For $ii = 1 To 17 $lines = FileReadLine($ConfigFileSaved) If $ii = 1 Then Local $LiveConfig = FileOpen($sConfig, 2) ;Write mode erase prev contents Else Local $LiveConfig = FileOpen($sConfig, 1) ;Write mode append to end of file EndIf If StringLeft($lines, 2) <> StringLeft($NewConfigLine, 2) Then ;Just open the actual config.txt file and write this line as $lines FileWrite($LiveConfig, $lines & @CRLF) Else ;It is the new line so do this FileWrite($LiveConfig, $NewConfigLine & @CRLF) $x = StringLeft($NewConfigLine, 2) Select Case $x = "01" $sFolderToBackup01 = $NewConfigLine ChkForFile($NewConfigLine) Case $x = "02" $sFolderToBackup02 = $NewConfigLine ChkForFile($NewConfigLine) Case $x = "03" $sFolderToBackup03 = $NewConfigLine ChkForFile($NewConfigLine) Case $x = "04" $sFolderToBackup04 = $NewConfigLine ChkForFile($NewConfigLine) Case $x = "05" $sFolderToBackup05 = $NewConfigLine ChkForFile($NewConfigLine) Case $x = "06" $sFolderToBackup06 = $NewConfigLine ChkForFile($NewConfigLine) Case $x = "07" $sFolderToBackup07 = $NewConfigLine ChkForFile($NewConfigLine) Case $x = "08" $sFolderToBackup08 = $NewConfigLine ChkForFile($NewConfigLine) Case $x = "09" $sFolderToBackup09 = $NewConfigLine ChkForFile($NewConfigLine) Case $x = "10" $sFolderToBackup10 = $NewConfigLine ChkForFile($NewConfigLine) Case $x = "11" $sFolderToBackup11 = $NewConfigLine ChkForFile($NewConfigLine) Case $x = "12" $sFolderToBackup12 = $NewConfigLine ChkForFile($NewConfigLine) Case $x = "13" $sFolderToBackup13 = $NewConfigLine ChkForFile($NewConfigLine) Case $x = "14" $sFolderToBackup14 = $NewConfigLine ChkForFile($NewConfigLine) Case $x = "15" $sFolderToBackup15 = $NewConfigLine ChkForFile($NewConfigLine) Case $x = "16" $sBUDriveLocation = $NewConfigLine Case $x = "17" $seMailFilesLocation = $NewConfigLine EndSelect EndIf FileClose($LiveConfig) Next FileClose($ConfigFileSaved) FileClose($LiveConfig) MsgBox(0,@ScriptLineNumber,"Got to here just before showlist in the 'change' routine") GUICtrlDelete($FolderList) MsgBox(0,@ScriptLineNumber,$FolderList & " if deleted ok would be not 0") MsgBox(0,@ScriptLineNumber,"Got to here, just before create the list") $FolderList = GUICtrlCreateList("-------Folder Location-------", 137, 125, 260, 320, "");was 310 MsgBox(0,@ScriptLineNumber,$FolderList & " Got to here, just after create the list") GUICtrlSetFont(-1, 9, 400, 1, $font) MsgBox(0,@ScriptLineNumber,$sFolderToBackup01 & " " & $sFolderToBackup15) GUICtrlSetData(-1, $sFolderToBackup01 & "|" & $sFolderToBackup02 & "|" & $sFolderToBackup03 & "|" & _ $sFolderToBackup04 & "|" & $sFolderToBackup05 & "|" & _ $sFolderToBackup06 & "|" & $sFolderToBackup07 & "|" & _ $sFolderToBackup08 & "|" & $sFolderToBackup09 & "|" & _ $sFolderToBackup10 & "|" & $sFolderToBackup11 & "|" & _ $sFolderToBackup12 & "|" & $sFolderToBackup13 & "|" & _ $sFolderToBackup14 & "|" & $sFolderToBackup15 & "|" & _ $sBUDriveLocation & "|" & $seMailFilesLocation & "|", _ $sFolderToBackup01) ; add other item and set a new default EndFunc ;==>Change ;It's the GUICtrlCreateList in this function that fails ......................................................... Func Remove() FileCopy($sConfig, $sConfigSaved, 1) Local $file = FileOpen($sConfig, 0) ;Read mode Global $sSavedSel = GUICtrlRead($FolderList) ;ie "02 C:Apps" The one that is selected by the user MsgBox(0,@ScriptLineNumber,$ssavedsel) While 1 If StringTrimLeft($sSavedSel, 3) = "NOT USED" Then Beep(390, 400) _extMsgBox(16, 0, "Invalid " & @ScriptLineNumber, "Cannot remove a selection that has already been removed, " & @CRLF & _ "Try 'Change' if you are trying to set up a new folder to backup", 0, 20, 400) Return EndIf If StringLeft(GUICtrlRead($FolderList), 29) = "-------Folder Location-------" Then Beep(390, 400) _extMsgBox(16, 0, "Error " & @ScriptLineNumber, "You have selected a invalid line. 'Folder Location'" & @CRLF & "Your selection is invalid, try again...", 0, 20, 400) Return EndIf If StringLeft(GUICtrlRead($FolderList), 2) = 16 Then Beep(390, 400) _extMsgBox(16, 0, "Do Not Remove this one " & @ScriptLineNumber, "The backup drive location " & @CRLF & "'" & $sBUDriveLocation & "'" & @CRLF & _ "should not be changed to 'NOT USED', but, you can use" & @CRLF & "'Change' Button to change it to a new location", 0, 20, 490) Return EndIf If StringLeft(GUICtrlRead($FolderList), 2) = 17 Then Beep(390, 400) _extMsgBox(16, 0, "Do Not Remove this one " & @ScriptLineNumber, "The eMail Folder drive location " & @CRLF & "'" & $seMailFilesLocation & "'" & @CRLF & _ "should not be changed to 'NOT USED', but , you can use" & @CRLF & "'Change' Button to change it to a new location", 0, 20, 510) Return EndIf $x = StringLeft($sSavedSel, 2) ;"02", "03" etc ExitLoop WEnd MsgBox(0,@ScriptLineNumber,"Got to here, inside remove routine") FileClose($file) ;Config.txt live file Local $ConfigFileSaved = FileOpen($sConfigSaved, 0) ;Read mode for configSaved.txt If $ConfigFileSaved = -1 Then Beep(390, 400) _extMsgBox(16, "Error " & @ScriptLineNumber, "The configSaved.txt file did not open properly" & @CRLF & _ "Cannot continue, exiting program", 0, 20, 400) Exit EndIf MsgBox(0,@ScriptLineNumber,"Got to here, again inside remove routine") For $ii = 1 To 17 $lines = FileReadLine($ConfigFileSaved) If $ii = 1 Then ;Just starting so erase prev contents Local $LiveConfig = FileOpen($sConfig, 2) ;Write mode erase prev contents Else Local $LiveConfig = FileOpen($sConfig, 1) ;Write mode append to end of file EndIf If StringLeft($lines, 2) <> $x Then ;Just open the actual config.txt file and write this line as $lines FileWrite($LiveConfig, $lines & @CRLF) Else ;It is the new line If $x <> "16" And $x <> "17" Then ; Must have been 1 - 15 so continue $ans = _extMsgBox(32, 4, "Configured backup Folder to be removed " & @ScriptLineNumber, "'" & $sSavedSel & "' will be removed from the" & @CRLF & _ "configured list and replaced with 'NOT USED' ... continue? ...", 0, 20, 400) If $ans = 1 Then ;1 = yes $newsel = $x & " NOT USED" FileWrite($LiveConfig, $newsel & @CRLF) ;Write the 'NOT USED' Else FileWrite($LiveConfig, $lines & @CRLF) $newsel = $lines EndIf EndIf Select Case $x = "01" $sFolderToBackup01 = $newsel Case $x = "02" $sFolderToBackup02 = $newsel Case $x = "03" $sFolderToBackup03 = $newsel Case $x = "04" $sFolderToBackup04 = $newsel Case $x = "05" $sFolderToBackup05 = $newsel Case $x = "06" $sFolderToBackup06 = $newsel Case $x = "07" $sFolderToBackup07 = $newsel Case $x = "08" $sFolderToBackup08 = $newsel Case $x = "09" $sFolderToBackup09 = $newsel Case $x = "10" $sFolderToBackup10 = $newsel Case $x = "11" $sFolderToBackup11 = $newsel Case $x = "12" $sFolderToBackup12 = $newsel Case $x = "13" $sFolderToBackup13 = $newsel Case $x = "14" $sFolderToBackup14 = $newsel Case $x = "15" $sFolderToBackup15 = $newsel EndSelect EndIf FileClose($LiveConfig) Next FileClose($ConfigFileSaved) FileClose($LiveConfig) MsgBox(0,@ScriptLineNumber,"Got to here, in remove before calling showlist") MsgBox(0,@ScriptLineNumber,"Got to remove, next is delete folderlist, then create folderlist") GUICtrlDelete($FolderList) MsgBox(0,@ScriptLineNumber,$FolderList) MsgBox(0,@ScriptLineNumber,"Got to remove, just before create the list") $FolderList = GUICtrlCreateList("-------Folder Location-------", 137, 125, 260, 320, "") MsgBox(0,@ScriptLineNumber,"0 is failure to create the list " & $FolderList) MsgBox(0,@ScriptLineNumber,"Got to remove, just after create the list, next is setfont which fails") GUICtrlSetFont($FolderList, 9, 400, 1, $font) MsgBox(0,@ScriptLineNumber,$sFolderToBackup01 & " " & $sFolderToBackup15) GUICtrlSetData(-1, $sFolderToBackup01 & "|" & $sFolderToBackup02 & "|" & $sFolderToBackup03 & "|" & _ $sFolderToBackup04 & "|" & $sFolderToBackup05 & "|" & _ $sFolderToBackup06 & "|" & $sFolderToBackup07 & "|" & _ $sFolderToBackup08 & "|" & $sFolderToBackup09 & "|" & _ $sFolderToBackup10 & "|" & $sFolderToBackup11 & "|" & _ $sFolderToBackup12 & "|" & $sFolderToBackup13 & "|" & _ $sFolderToBackup14 & "|" & $sFolderToBackup15 & "|" & _ $sBUDriveLocation & "|" & $seMailFilesLocation & "|", _ $sFolderToBackup01) ; add other item and set a new default MsgBox(0,@ScriptLineNumber,"Got to here, in remove after showList and setdata") If $x <> "16" And $x <> "17" And $ans = 1 Then $ans = _extMsgBox(32, 4, "Remove folder ?? " & @ScriptLineNumber, "Want to also remove the folder, all subfolders, and all files in" & @CRLF & StringTrimLeft($sBUDriveLocation, 3) & _ "" & StringTrimLeft($sSavedSel, 6) & "' from the backup drive?", 0, 20, 450) ;32 is Query "?" If $ans = 1 Then ; 1 is yes ;remove it from backup drive here _extMsgBox(128, " ", "Remove Folder " & @ScriptLineNumber, "About to remove the folder from backup drive ... " & StringTrimLeft($sBUDriveLocation, 3) _ & "" & StringTrimLeft($sSavedSel, 6), 5, 20, 400) ; 128 is countdown DirRemove(StringTrimLeft($sBUDriveLocation, 3) & "" & StringTrimLeft($sSavedSel, 6), 1) ;1=remove files and subdirectories _extMsgBox(128, " ", "REMOVED ALL", "Deleted all files and subdirectories in " & StringTrimLeft($sBUDriveLocation, 3) _ & "" & StringTrimLeft($sSavedSel, 6), 5, 20, 400) Else _extMsgBox(128, " ", "Result - FILES NOT REMOVED", StringTrimLeft($sBUDriveLocation, 3) & "" & StringTrimLeft($sSavedSel, 5) _ & " Folder was NOT REMOVED from backup drive", 5, 20, 400) ; 48 is "!" EndIf EndIf EndFunc ;==>Remove Link to comment Share on other sites More sharing options...
cyberalau3 Posted February 4, 2015 Author Share Posted February 4, 2015 Here it is ... Link to comment Share on other sites More sharing options...
MikahS Posted February 4, 2015 Share Posted February 4, 2015 Well, using code tags would take down the size of your post considerably. use code tags like so: [ autoit ] ;code goes here [ /autoit ] (remove the spaces) see: Local $test = "test var" ; this is a test Why don't you edit your post and put it in code tags while I take a look.. Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
MikahS Posted February 4, 2015 Share Posted February 4, 2015 (edited) Also, what do you mean by doesn't work? Doesn't create the list? You get back 0 when creating the list? Edited February 4, 2015 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
cyberalau3 Posted February 4, 2015 Author Share Posted February 4, 2015 I'v never posted any code and don't know how to do it right. Sorry ... If it is too difficult to work with what I provided, I completely understand. I'm an old fart (72) and just doing this for my own use and entertainment. Up to this point, I'v been able to solve my issues by simply reading through the forums. "Old programmers never die, they just lose their code" Link to comment Share on other sites More sharing options...
MikahS Posted February 4, 2015 Share Posted February 4, 2015 (edited) No problem. You would just edit your post and add those code tags above and below the code you already posted. But, I played with it and both were created fine. I think you need to change the title of the List for either the first or the second, it could cause confusion because it looks exactly the same. I can see that you are checking your return value from each list creation, which is very good, is it definitely returning a 0 when you go to create this second item? Edited February 4, 2015 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
cyberalau3 Posted February 4, 2015 Author Share Posted February 4, 2015 Yes, I get a 0 and the following GUICtrlSetFont completely booms AutoIt I guess because the control didn't get created Link to comment Share on other sites More sharing options...
cyberalau3 Posted February 4, 2015 Author Share Posted February 4, 2015 I'll try changing the title as you mention and get right back to you Link to comment Share on other sites More sharing options...
MikahS Posted February 4, 2015 Share Posted February 4, 2015 I just feel it is something that is going on outside of the script you posted, or maybe something that is being overlooked. Did you check to see if you had deleted the first list before trying to create another? That would be as easy as doing the same thing with MsgBox, but just checking the value of Local $f_Delete = GUICtrlDelete($FolderList) MsgBox(0, "deletion of folderlist", $f_Delete) Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
cyberalau3 Posted February 4, 2015 Author Share Posted February 4, 2015 I am pretty sure it is being deleted because the list actually disappears Link to comment Share on other sites More sharing options...
cyberalau3 Posted February 4, 2015 Author Share Posted February 4, 2015 changing the text (title) doesn't change anything. It doesn't get created and then when the the GUICtrlSetFont triggers, it kills AutoIt all together Link to comment Share on other sites More sharing options...
cyberalau3 Posted February 4, 2015 Author Share Posted February 4, 2015 I have to go out for about a half hour, will check back after I return .. Thanks for looking at this for me Link to comment Share on other sites More sharing options...
MikahS Posted February 4, 2015 Share Posted February 4, 2015 changing the text (title) doesn't change anything. It doesn't get created and then when the the GUICtrlSetFont triggers, it kills AutoIt all together Try putting the list into a new variable. I'm sure you are fine, but making everything of the second list seperate from the first list naming conventions could help us find a solution. Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
cyberalau3 Posted February 4, 2015 Author Share Posted February 4, 2015 Don't give up on me, I am trying some different ideas all together. I did try the naming solution with no positive results .. Link to comment Share on other sites More sharing options...
MikahS Posted February 5, 2015 Share Posted February 5, 2015 There has to be something going on to stop the creation of this list. It might be worth a shot trying to create other ctrls to see if they do the same thing as the list did. Like a listview or an edit control. It might be something with the list, but I still think it's something that hasn't been shown yet. Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
cyberalau3 Posted February 10, 2015 Author Share Posted February 10, 2015 I truely appreciate all the help. I finally gave up and got away from creating a list to do what I wanted and just created a bunch of check boxes. Not as elegant but I began wondering if there was a bug in the list routine. I kind of doubt that, more likely something I am over looking. Once again, thanks for the help. This is a great forum. Cyberal 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