Tasmania Posted October 4, 2007 Share Posted October 4, 2007 (edited) My application loads a GUI, and has multiple gui windows located beneath the main gui. One of these gui windows is called Heat Seal tool where you input information on a HST in there, and you can have it be common to or a duplicate of a tool number. I have this setup as a checkbox with the name $chkDup, and if it is checked it sets another label to Duplicate of: and if not checked it names it Common to:. It runs fine until I try to Open a file, whereas it just won't check the checkbox. It is not an error in save, as the value is stored correctly inside of the file. My code is setup as follows: Open: expandcollapse popupFunc open() $fileopenloc = FileOpenDialog("Open...", @MyDocumentsDir & "\Syte Line Automation\", "Syte Line Automation Files (*.sla)") If Not @error Then $edtcnts = "" GUICtrlSetData($txtAttn, IniRead($fileopenloc, "PRIMARY DATA", "Attn", "Unknown")) GUICtrlSetData($txtEmail, IniRead($fileopenloc, "PRIMARY DATA", "Email", "Unknown")) GUICtrlSetData($txtPwo, IniRead($fileopenloc, "PRIMARY DATA", "PWO", "Unknown")) GUICtrlSetData($txtSca, IniRead($fileopenloc, "PRIMARY DATA", "SCA", "Unknown")) GUICtrlSetData($txtDesc, IniRead($fileopenloc, "PRIMARY DATA", "Desc", "Unknown")) $filedate = IniRead($fileopenloc, "PRIMARY DATA", "RqstDte", "1/1/1955") $filedatearr = StringSplit($filedate, "/") $newdate = $filedatearr[3] & "/" & $filedatearr[1] & "/" & $filedatearr[2] GUICtrlSetData($dteRstdate, $newdate) GUICtrlSetData($txtPE, IniRead($fileopenloc, "PRIMARY DATA", "PE", "Unknown")) GUICtrlSetData($txtPM, IniRead($fileopenloc, "PRIMARY DATA", "PM", "Unknown")) GUICtrlSetData($txtCharge, IniRead($fileopenloc, "PRIMARY DATA", "Charge", "Unknown")) $ponum = IniRead($fileopenloc, "PO INFORMATION", "PONum", "Unknown") $poamt = IniRead($fileopenloc, "PO INFORMATION", "POAmt", "Unknown") $podisc = IniRead($fileopenloc, "PO INFORMATION", "PODisc", "Unknown") $qty = IniRead($fileopenloc, "SECONDARY INFORMATION", "QTY", "Unknown") $type = IniRead($fileopenloc, "ITEM INFORMATION", "Type", "CONCEPT") $pcode = IniRead($fileopenloc, "ITEM INFORMATION", "ProdCode", "SAM-CONCPT") $material = IniRead($fileopenloc, "BFT INFORMATION", "Material", "Unknown") $gauge = IniRead($fileopenloc, "BFT INFORMATION", "Gauge", "Unknown") $bicnotes = IniRead($fileopenloc, "SECONDARY INFORMATION", "BICNotes", "0") $bicnoteschecked = IniRead($fileopenloc, "SECONDARY INFORMATION", "BICNotesChecked", "0") $dupof = IniRead($fileopenloc, "HST INFORMATION", "DupOF", "Unknown") $comto = IniRead($fileopenloc, "HST INFORMATION", "ComTO", "Unknown") $comdup = IniRead($fileopenloc, "HST INFORMATION", "Item", "Unknown") $cid = IniRead($fileopenloc, "HST INFORMATION", "CustItmDesc", "Unknown") $consistingof_FROMINI = IniRead($fileopenloc, "HST INFORMATION", "ConsistingOf", "Unknown") $consisting = StringReplace($consistingof_FROMINI, "\r\n", @CRLF) $exnotes_FROMINI = IniRead($fileopenloc, "SECONDARY INFORMATION", "ExNotes", "Unknown") $exnotes = StringReplace($exnotes_FROMINI, "\r\n", @CRLF) $pcodedefset = 1 $firsthst = 0 $firstbft = 0 Switch $type Case StringUpper("Concept") GUICtrlSetState($mnuConcept, $GUI_CHECKED) GUICtrlSetState($mnuReconcept, $GUI_UNCHECKED) GUICtrlSetState($mnuSample, $GUI_UNCHECKED) GUICtrlSetState($mnuResample, $GUI_UNCHECKED) GUICtrlSetState($mnuAddSam, $GUI_UNCHECKED) GUICtrlSetState($mnuHST, $GUI_UNCHECKED) GUICtrlSetState($mnuBFT, $GUI_UNCHECKED) Case StringUpper("Reconcept") GUICtrlSetState($mnuConcept, $GUI_UNCHECKED) GUICtrlSetState($mnuReconcept, $GUI_CHECKED) GUICtrlSetState($mnuSample, $GUI_UNCHECKED) GUICtrlSetState($mnuResample, $GUI_UNCHECKED) GUICtrlSetState($mnuAddSam, $GUI_UNCHECKED) GUICtrlSetState($mnuHST, $GUI_UNCHECKED) GUICtrlSetState($mnuBFT, $GUI_UNCHECKED) Case StringUpper("Sample") GUICtrlSetState($mnuConcept, $GUI_UNCHECKED) GUICtrlSetState($mnuReconcept, $GUI_UNCHECKED) GUICtrlSetState($mnuSample, $GUI_CHECKED) GUICtrlSetState($mnuResample, $GUI_UNCHECKED) GUICtrlSetState($mnuAddSam, $GUI_UNCHECKED) GUICtrlSetState($mnuHST, $GUI_UNCHECKED) GUICtrlSetState($mnuBFT, $GUI_UNCHECKED) Case StringUpper("Resample") GUICtrlSetState($mnuConcept, $GUI_UNCHECKED) GUICtrlSetState($mnuReconcept, $GUI_UNCHECKED) GUICtrlSetState($mnuSample, $GUI_UNCHECKED) GUICtrlSetState($mnuResample, $GUI_CHECKED) GUICtrlSetState($mnuAddSam, $GUI_UNCHECKED) GUICtrlSetState($mnuHST, $GUI_UNCHECKED) GUICtrlSetState($mnuBFT, $GUI_UNCHECKED) Case StringUpper("Additional Sample") GUICtrlSetState($mnuConcept, $GUI_UNCHECKED) GUICtrlSetState($mnuReconcept, $GUI_UNCHECKED) GUICtrlSetState($mnuSample, $GUI_UNCHECKED) GUICtrlSetState($mnuResample, $GUI_UNCHECKED) GUICtrlSetState($mnuAddSam, $GUI_CHECKED) GUICtrlSetState($mnuHST, $GUI_UNCHECKED) GUICtrlSetState($mnuBFT, $GUI_UNCHECKED) Case StringUpper("Heat Seal Tool") GUICtrlSetState($mnuConcept, $GUI_UNCHECKED) GUICtrlSetState($mnuReconcept, $GUI_UNCHECKED) GUICtrlSetState($mnuSample, $GUI_UNCHECKED) GUICtrlSetState($mnuResample, $GUI_UNCHECKED) GUICtrlSetState($mnuAddSam, $GUI_UNCHECKED) GUICtrlSetState($mnuHST, $GUI_CHECKED) GUICtrlSetState($mnuBFT, $GUI_UNCHECKED) Case StringUpper("Blister Form Tool") GUICtrlSetState($mnuConcept, $GUI_UNCHECKED) GUICtrlSetState($mnuReconcept, $GUI_UNCHECKED) GUICtrlSetState($mnuSample, $GUI_UNCHECKED) GUICtrlSetState($mnuResample, $GUI_UNCHECKED) GUICtrlSetState($mnuAddSam, $GUI_UNCHECKED) GUICtrlSetState($mnuHST, $GUI_UNCHECKED) GUICtrlSetState($mnuBFT, $GUI_CHECKED) GUICtrlSetState($mnuAddMG, $GUI_ENABLE) EndSwitch If Not Mod($bicnoteschecked, 2) Then GUICtrlSetState($mnuBicNotes, $GUI_CHECKED) Else GUICtrlSetState($mnuBicNotes, $GUI_UNCHECKED) EndIf EndIf EndFuncoÝ÷ Ù'¥yËbÒMúèØ^éîjëh×6Func mnu_hst() $type = "HEAT SEAL TOOL" If Not $pcodedefset Then $pcode = "MAH-FAC" $pcodedefset = 1 EndIf If $dupof And Not $comto Then $lblComDupDisplay = "D&uplicate Of:" EndIf If $comto And Not $dupof Then $lblComDupDisplay = "Common &To:" EndIf #Region ### START Koda GUI section ### Form=c:\documents and settings\uspjefe\desktop\projects\frmhsttype.kxf $frmHSTType = GUICreate("Which Type?", 178, 306, -1, -1, BitOR($WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS), -1, $frmSLA) $lblHSTTypeHeader = GUICtrlCreateLabel("Heat Seal Tool Information", 0, 0, 177, 17, $SS_CENTER) GUICtrlSetFont(-1, 8, 400, 4, "MS Sans Serif") $lblComDup = GUICtrlCreateLabel($lblComDupDisplay, 8, 24, 70, 17) $txtComDup = GUICtrlCreateInput($comdup, 8, 48, 161, 21, BitOR($ES_UPPERCASE,$ES_AUTOHSCROLL)) $chkDup = GUICtrlCreateCheckbox("&Duplicate", 88, 24, 81, 17) $lblCID = GUICtrlCreateLabel("Customer &Item Description:", 8, 72, 136, 17) $txtCID = GUICtrlCreateInput($cid, 8, 96, 161, 21, BitOR($ES_UPPERCASE,$ES_AUTOHSCROLL)) GUICtrlSetTip(-1, "The Customer Item field on the Detail Tab of Order Line Maintenance.") $lblConsisting = GUICtrlCreateLabel("Consisting &Of:", 8, 120, 75, 17) $edtConsisting = GUICtrlCreateEdit("", 8, 144, 161, 97, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$ES_UPPERCASE)) GUICtrlSetData(-1, $consisting) $rdoFAC = GUICtrlCreateRadio("MAH-&FAC", 8, 248, 73, 17) GUICtrlSetState(-1, $GUI_CHECKED) $rdoFAM = GUICtrlCreateRadio("MAH-FA&M", 96, 248, 73, 17) $btnHSTContinue = GUICtrlCreateButton("&Continue", 8, 272, 75, 25, $BS_DEFPUSHBUTTON) $btnHSTCancel = GUICtrlCreateButton("C&ancel", 96, 272, 75, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### If $dupof And Not $comto Then GUICtrlSetState($chkDup, $GUI_CHECKED) EndIf If $comto And Not $dupof Then GUICtrlSetState($chkDup, $GUI_UNCHECKED) EndIf If $firsthst Then GUICtrlSetState($btnHSTCancel, $GUI_DISABLE) Else GUICtrlSetState($btnHSTCancel, $GUI_ENABLE) EndIf If $pcode = "MAH-FAC" Then GUICtrlSetState($rdoFAC, $GUI_CHECKED) GUICtrlSetState($rdoFAM, $GUI_UNCHECKED) Else GUICtrlSetState($rdoFAM, $GUI_CHECKED) GUICtrlSetState($rdoFAC, $GUI_UNCHECKED) EndIf While 1 $nMsg = GUIGetMsg() Switch $nMsg ;Case $GUI_EVENT_CLOSE ;GUISetState(@SW_HIDE, $frmHSTType) ;ExitLoop Case $btnHSTCancel GUISetState(@SW_HIDE, $frmHSTType) ExitLoop Case $chkDup If $dupof Then GUICtrlSetData($lblComDup, "Common &To:") $dupof = 0 $comto = 1 Else GUICtrlSetData($lblComDup, "D&uplicate Of:") $dupof = 1 $comto = 0 EndIf Case $rdoFAC $pcode = "MAH-FAC" Case $rdoFAM $pcode = "MAH-FAM" Case $btnHSTContinue GUISetState(@SW_HIDE, $frmHSTType) $cid = GUICtrlRead($txtCID) $consisting = GUICtrlRead($edtConsisting) $comdup = GUICtrlRead($txtComDup) ExitLoop EndSwitch WEnd $firsthst = 0 EndFunc See attached files for the script. EDIT: Ok so apparently you have to set anything = 1 when verifying through an If statement. Interesting, but not the end of the world. Fixed. Edited October 4, 2007 by Tasmania Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 4, 2007 Share Posted October 4, 2007 (edited) EDIT: Ok so apparently you have to set anything = 1 when verifying through an If statement. Interesting, but not the end of the world. Fixed. Yeah, this is always dangerous phrasing, and trips me up regularly: If $dupof And Not $comto Then GUICtrlSetState($chkDup, $GUI_CHECKED) EndIf If $comto And Not $dupof Then GUICtrlSetState($chkDup, $GUI_UNCHECKED) EndIf The problem is order of operations. NOT has a higher priority than anything else, and that makes for unexpected results. Plus, if any of those variables are non-numeric strings, they will be evaluated numerically as 0, therefore boolean FALSE. You can make it work if you're careful, and this part may not even be your issue, but it catches my eye as a problem area for me. That looks like my kind of script, BTW, gett'n real work done, not a bot for some stupid game. Cool. Edited October 4, 2007 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Tasmania Posted October 4, 2007 Author Share Posted October 4, 2007 Hehe, yeah that's what got me too. Originally I just had If $dupof Then, but then I changed it to the Not, then I added the And, and finally, the working script reads as: If $dupof = 1 Then For some reason, I had to assign it a value of 1, as it wasn't interpreting 1 as true in this instance. It was weird. Thanks for the help Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 4, 2007 Share Posted October 4, 2007 Hehe, yeah that's what got me too. Originally I just had If $dupof Then, but then I changed it to the Not, then I added the And, and finally, the working script reads as: If $dupof = 1 Then For some reason, I had to assign it a value of 1, as it wasn't interpreting 1 as true in this instance. It was weird. Thanks for the help That's strange. AutoIt does some automatic variable type changes in the background for arithmetic expression, like 123 + "456", and a non-numeric string evaluates as 0 in arithmetic operation: $A = 123 + "456" ConsoleWrite("Debug: $A = " & $A & @LF) $A = 123 * "0" ConsoleWrite("Debug: $A = " & $A & @LF) $A = 123 * "OneTwoThree" ConsoleWrite("Debug: $A = " & $A & @LF) But that re-typing doesn't extend to boolean operations. Numeric 0 is False, and null string is False. All non-zero numbers and all non-null strings are True, including "0": expandcollapse popup$A = 0 If $A Then ConsoleWrite("Debug: TestA_0 = True" & @LF) Else ConsoleWrite("Debug: TestA_0 = False" & @LF) EndIf $A = 2 If $A Then ConsoleWrite("Debug: TestA_2 = True" & @LF) Else ConsoleWrite("Debug: TestA_2 = False" & @LF) EndIf $A = "0" If $A Then ConsoleWrite("Debug: TestA_string0 = True" & @LF) Else ConsoleWrite("Debug: TestA_string0 = False" & @LF) EndIf $A = "2" If $A Then ConsoleWrite("Debug: TestA_string2 = True" & @LF) Else ConsoleWrite("Debug: TestA_string2 = False" & @LF) EndIf $A = "Zero" If $A Then ConsoleWrite("Debug: TestA_stringZero = True" & @LF) Else ConsoleWrite("Debug: TestA_stringZero = False" & @LF) EndIf $A = "" If $A Then ConsoleWrite("Debug: TestA_nul = True" & @LF) Else ConsoleWrite("Debug: TestA_nul = False" & @LF) EndIf If that all seems natural and obvious to you... you're a geek. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Tasmania Posted October 4, 2007 Author Share Posted October 4, 2007 (edited) Heheh, it all does. But that's not the scary part... the scary part is that I didn't have to go back and re-read it to understand it.Of course, to me, AutoIt is generally very easy to understand and even easier to code... coming from PHP with interface to MySQL...Edit: Just for clarification, the hard part of AutoIt is that there are a lot of addon functions and such that are not able to be listed in the help file, and there are some "syntax quirks" in autoit... compared to C# or Visual Basic or PHP or um... a lot of the other programming languages out there... hehe. Edited October 4, 2007 by Tasmania 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