goodmanjl531 Posted April 30 Posted April 30 (edited) I have a program with a GUI interface that is mainly for decoding files. it has multiple label fields to show raw/decoded/parsed data. It has 3 buttons at button that work (next Record, Previous Record and Exit) The issue is the text will disappear randomly on the buttons. I refresh the labels for each new record as it is decoded, but I cannot figure our why the button text disappears. everything works correctly except the fact the words on my buttons go away and come back randomly. I have redacted a majority of the code as it is redundant for the different records i decode and will make it easier as it still has an error with less code. 1 button missing text 2 buttons missing text here is some sample text used that will decode.. 0010048150 0000500730000010000000000399000000039900000003990000000000010000000399010000000000000 0010048627 0000500730000010000000000399000000039900000003990000000000010000000399011000000000000 0010047109 0000500730000010000000000399000000039900000003990000000000010000000399011000000000000 expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <Array.au3> #include <MsgBoxConstants.au3> Global $Form_record, $MaxRecords, $Form_Main, $Btn_Exit, $Btn_Next, $Btn_Prev, $record[26], $record_parsed[26], $Label7, $Label[26], $GUI_LBL[26], $GUI_input[26], $GUI_input_parsed[26], $TlogArray, $sFile_tlog_path = "C:\TS\tlog.new" _FileReadToArray($sFile_tlog_path, $TlogArray) ; Read TLOG file and add to an array to be able to read line by line $Totalrows = UBound($TlogArray) $MaxRecords = $Totalrows - 1 For $ind = 1 To 25 $record[$ind] = " " $record_parsed[$ind] = " " $Label[$ind] = " " Next $RecordName = "TLOG Decoder" Call("Build_Form", $RecordName, $record, $record_parsed, $Label) GUISetState(@SW_SHOW, $Form_record) Sleep(1000) $row = 1 Do $tempRec = $TlogArray[$row] $rectype = StringLeft($tempRec, 3) Select Case $rectype = "001" $RecordName = "String Type 001 - Merchandise Item" Call("REC001", $tempRec) Case $rectype = "004" $RecordName = "String Type 004 - Fee" Call("REC004", $tempRec) Case Else ; NON Coded response MsgBox(0, "Claires TLOG DECODER - JLG", "Code " & $rectype & " Not found") EndSelect Call("Update_Form", $RecordName, $record, $record_parsed, $Label) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($Form_record) Exit Case $Btn_Exit GUIDelete($Form_record) Exit Case $Btn_Next $row += 1 ExitLoop Case $Btn_Prev $row -= 1 ExitLoop EndSwitch WEnd If $row > $MaxRecords Then MsgBox(0, "TLOG Decoder", "Last Record Nothing After") $row -= 1 EndIf If $row < 1 Then MsgBox(0, "TLOG Decoder", "First record nothing prior") $row = 1 EndIf Until $row > $MaxRecords Exit ; **** END OF MAIN PROGRAM*** Func Dollar($record) Return ("$ " & StringFormat("%.2f", $record / 100)) EndFunc ;==>Dollar Func ConvertToDate($record) Return (StringTrimRight($record, 6) & "/" & StringMid($record, 3, 2) & "/" & StringTrimLeft($record, 4)) EndFunc ;==>ConvertToDate Func ConvertToPercentage($record) Return (StringFormat("%.5f,", $record / 100000) & " %") EndFunc ;==>ConvertToPercentage Func ConvertToXDecimals($record, $Precision) Switch $Precision Case 1 $mult = 10 $newnumb = (StringFormat("%.1f", $record / $mult)) Case 2 $mult = 100 $newnumb = (StringFormat("%.2f", $record / $mult)) Case 3 $mult = 1000 $newnumb = (StringFormat("%.3f", $record / $mult)) Case 4 $mult = 10000 $newnumb = (StringFormat("%.4f", $record / $mult)) Case 5 $mult = 100000 $newnumb = (StringFormat("%.5f", $record / $mult)) Case 6 $mult = 1000000 $newnumb = (StringFormat("%.6f", $record / $mult)) EndSwitch Return ($newnumb) EndFunc ;==>ConvertToXDecimals Func Sign($record) If $record = "0" Then Return ("Positive") Else Return ("Negative") EndIf EndFunc ;==>Sign Func Build_Form($RecordName, $record, $record_parsed, $Label) ;--> Build form For $ind = 1 To 25 $record[$ind] = " " $record_parsed[$ind] = " " $Label[$ind] = " " Next $Form_record = GUICreate("TLOG DECODER 101 - JLG", 1623, 798, 228, 88) GUICtrlCreateLabel("Description", 24, 8, 145, 21, $SS_CENTER) $GUI_LBL[1] = GUICtrlCreateLabel("1", 24, 50, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_LBL[2] = GUICtrlCreateLabel("2", 24, 126, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_LBL[3] = GUICtrlCreateLabel("3", 24, 203, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_LBL[4] = GUICtrlCreateLabel("4", 24, 281, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_LBL[5] = GUICtrlCreateLabel("5", 24, 358, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_LBL[6] = GUICtrlCreateLabel("6", 24, 436, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_LBL[7] = GUICtrlCreateLabel("7", 24, 513, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_LBL[8] = GUICtrlCreateLabel("8", 24, 591, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlCreateLabel("RAW", 175, 8, 145, 21, $SS_CENTER) $GUI_input[1] = GUICtrlCreateLabel("9", 175, 50, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input[2] = GUICtrlCreateLabel("10", 175, 126, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input[3] = GUICtrlCreateLabel("11", 175, 203, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input[4] = GUICtrlCreateLabel("12", 175, 281, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input[5] = GUICtrlCreateLabel("13", 175, 358, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input[6] = GUICtrlCreateLabel("14", 175, 436, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input[7] = GUICtrlCreateLabel("15", 175, 513, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input[8] = GUICtrlCreateLabel("16", 175, 591, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlCreateLabel("PARSED", 329, 8, 145, 21, $SS_CENTER) $GUI_input_parsed[1] = GUICtrlCreateLabel("17", 329, 50, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input_parsed[2] = GUICtrlCreateLabel("18", 329, 126, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input_parsed[3] = GUICtrlCreateLabel("19", 329, 203, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input_parsed[4] = GUICtrlCreateLabel("20", 329, 281, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input_parsed[5] = GUICtrlCreateLabel("21", 329, 358, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input_parsed[6] = GUICtrlCreateLabel("22", 329, 436, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input_parsed[7] = GUICtrlCreateLabel("23", 329, 513, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input_parsed[8] = GUICtrlCreateLabel("24", 329, 591, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlCreateLabel("Description", 538, 17, 114, 21, $SS_CENTER) $GUI_LBL[9] = GUICtrlCreateLabel("25", 538, 50, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_LBL[10] = GUICtrlCreateLabel("26", 538, 126, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_LBL[11] = GUICtrlCreateLabel("27", 538, 203, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_LBL[12] = GUICtrlCreateLabel("28", 538, 281, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_LBL[13] = GUICtrlCreateLabel("29", 538, 358, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_LBL[14] = GUICtrlCreateLabel("30", 538, 436, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_LBL[15] = GUICtrlCreateLabel("31", 538, 513, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_LBL[16] = GUICtrlCreateLabel("32", 538, 591, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlCreateLabel("RAW", 690, 17, 145, 21, $SS_CENTER) $GUI_input[9] = GUICtrlCreateLabel("33", 690, 50, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input[10] = GUICtrlCreateLabel("34", 690, 126, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input[11] = GUICtrlCreateLabel("35", 690, 203, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input[12] = GUICtrlCreateLabel("36", 690, 281, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input[13] = GUICtrlCreateLabel("37", 690, 358, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input[14] = GUICtrlCreateLabel("38", 690, 436, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input[15] = GUICtrlCreateLabel("39", 690, 513, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input[16] = GUICtrlCreateLabel("40", 690, 591, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlCreateLabel("PARSED", 845, 17, 145, 21, $SS_CENTER) $GUI_input_parsed[9] = GUICtrlCreateLabel("41", 845, 50, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input_parsed[10] = GUICtrlCreateLabel("42", 845, 126, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input_parsed[11] = GUICtrlCreateLabel("43", 845, 203, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input_parsed[12] = GUICtrlCreateLabel("44", 845, 281, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input_parsed[13] = GUICtrlCreateLabel("45", 845, 358, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input_parsed[14] = GUICtrlCreateLabel("46", 845, 436, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input_parsed[15] = GUICtrlCreateLabel("47", 845, 513, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input_parsed[16] = GUICtrlCreateLabel("48", 845, 591, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlCreateLabel("Description", 1045, 17, 114, 21, $SS_CENTER) $GUI_LBL[17] = GUICtrlCreateLabel("49", 1045, 50, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_LBL[18] = GUICtrlCreateLabel("50", 1045, 126, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_LBL[19] = GUICtrlCreateLabel("51", 1045, 203, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_LBL[20] = GUICtrlCreateLabel("52", 1045, 281, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_LBL[21] = GUICtrlCreateLabel("53", 1045, 358, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_LBL[22] = GUICtrlCreateLabel("54", 1045, 436, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_LBL[23] = GUICtrlCreateLabel("55", 1045, 513, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_LBL[24] = GUICtrlCreateLabel("56", 1045, 591, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlCreateLabel("RAW", 1199, 17, 145, 21, $SS_CENTER) $GUI_input[17] = GUICtrlCreateLabel("57", 1199, 50, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input[18] = GUICtrlCreateLabel("58", 1199, 126, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input[19] = GUICtrlCreateLabel("59", 1199, 203, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input[20] = GUICtrlCreateLabel("60", 1199, 281, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input[21] = GUICtrlCreateLabel("61", 1199, 358, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input[22] = GUICtrlCreateLabel("62", 1199, 436, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input[23] = GUICtrlCreateLabel("63", 1199, 513, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input[24] = GUICtrlCreateLabel("64", 1199, 591, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlCreateLabel("PARSED", 1355, 17, 145, 21, $SS_CENTER) $GUI_input_parsed[17] = GUICtrlCreateLabel("65", 1355, 50, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input_parsed[18] = GUICtrlCreateLabel("66", 1355, 126, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input_parsed[19] = GUICtrlCreateLabel("67", 1355, 203, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input_parsed[20] = GUICtrlCreateLabel("68", 1355, 281, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input_parsed[21] = GUICtrlCreateLabel("69", 1355, 358, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input_parsed[22] = GUICtrlCreateLabel("70", 1355, 436, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input_parsed[23] = GUICtrlCreateLabel("71", 1355, 513, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input_parsed[24] = GUICtrlCreateLabel("72", 1355, 591, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $Btn_Prev = GUICtrlCreateButton("Previous Record", 499, 737, 209, 33) $Btn_Exit = GUICtrlCreateButton("Exit", 232, 736, 209, 33) $Btn_Next = GUICtrlCreateButton("Next Record", 1072, 736, 209, 33) $Label7 = GUICtrlCreateLabel("Record#", 776, 736, 166, 25) EndFunc ;==>Build_Form Func Update_Form($RecordName, $record, $record_parsed, $Label) ; MsgBox(0, "", "update - in") ;GUICtrlSetBkColor(-1, 0xFFFFFF) WinSetTitle($Form_record, "", $RecordName) ControlSetText("", "", $Label7, "Record " & $row & " of " & $MaxRecords) ControlSetText("", "", $Btn_Exit, "Exit") ControlSetText("", "", $Btn_Next, "Next Record") For $ind = 1 To 25 ControlSetText("", "", $GUI_LBL[$ind], $Label[$ind]) ControlSetText("", "", $GUI_input[$ind], $record[$ind]) ControlSetText("", "", $GUI_input_parsed[$ind], $record_parsed[$ind]) Next ControlSetText("", "", $GUI_input_parsed[1], $RecordName) GUISetState(@SW_SHOW, $Form_record) ; MsgBox(0, "", "update - out") EndFunc ;==>Update_Form Func REC001($TLOG) ;String type001 Merhcandise Item For $ind = 1 To 25 $record[$ind] = " " $record_parsed[$ind] = " " $Label[$ind] = "Not Used" Next $record[1] = StringMid($TLOG, 1, 3) $record[2] = StringMid($TLOG, 4, 1) If $record[2] = "1" Then $record_parsed[2] = "Voided" Else $record_parsed[2] = "Not Voided" EndIf $record[3] = StringMid($TLOG, 5, 1) If $record[3] = "1" Then $record_parsed[3] = "Exchanged" Else $record_parsed[3] = "Not Exchanged" EndIf $record[4] = StringMid($TLOG, 6, 24) $record[5] = StringMid($TLOG, 30, 1) If $record[5] = "1" Then $record_parsed[5] = "Class" Else $record_parsed[5] = "SKU" EndIf $record[6] = StringMid($TLOG, 31, 4) $record[7] = StringMid($TLOG, 35, 4) $record[8] = StringMid($TLOG, 39, 9) ;$record_parsed[8] = $record[8] / 1000 $record_parsed[8] = Call("ConvertToXDecimals", $record[8], 3) $record[9] = StringMid($TLOG, 48, 10) $record_parsed[9] = Call("Dollar", $record[9]) $record[10] = StringMid($TLOG, 58, 10) $record_parsed[10] = Call("Dollar", $record[10]) $record[11] = StringMid($TLOG, 68, 10) $record_parsed[11] = Call("Dollar", $record[11]) $record[12] = StringMid($TLOG, 78, 10) $record[13] = StringMid($TLOG, 88, 2) $record[14] = StringMid($TLOG, 90, 10) $record_parsed[14] = Call("Dollar", $record[14]) $record[15] = StringMid($TLOG, 100, 1) $record[16] = StringMid($TLOG, 101, 1) $record[17] = StringMid($TLOG, 102, 1) $record[18] = StringMid($TLOG, 103, 2) $record[19] = StringMid($TLOG, 105, 1) $record[20] = StringMid($TLOG, 106, 1) $record[21] = StringMid($TLOG, 107, 1) $record[22] = StringMid($TLOG, 108, 1) $record[23] = StringMid($TLOG, 109, 2) $record[24] = StringMid($TLOG, 111, 1) $record[25] = StringMid($TLOG, 112, 3) $Label[1] = "Identifier" $Label[2] = "Void Indicator" $Label[3] = "Exchange Indicator" $Label[4] = "Item Number" $Label[5] = "Sku/Class Indicator" $Label[6] = "Department Number" $Label[7] = "Class Number" $Label[8] = "Quantity" $Label[9] = "Price Original" $Label[10] = "Price On Lookup" $Label[11] = "Price Before Discount" $Label[12] = "Reserved for Future" $Label[13] = "Price Indicator" $Label[14] = "Extended Total" $Label[15] = "Not On File" $Label[16] = "Entry Indicator" $Label[17] = "Taxable Indicator " $Label[18] = "Item Status" $Label[19] = "Raincheck " $Label[20] = "Gift Item" $Label[21] = "Package" $Label[22] = "Send Item Indicator" $Label[23] = "Send to Location" $Label[24] = "Team Associate Item" $Label[25] = "Team Number" EndFunc ;==>REC001 Func REC004($TLOG) ; StringType:004 Fee For $ind = 1 To 25 $record[$ind] = " " $record_parsed[$ind] = " " $Label[$ind] = "Not Used" Next $record[1] = StringMid($TLOG, 1, 3) $record[2] = StringMid($TLOG, 4, 1) $record[3] = StringMid($TLOG, 5, 8) $record[4] = StringMid($TLOG, 13, 10) $record[5] = StringMid($TLOG, 23, 1) $record[6] = StringMid($TLOG, 24, 1) $record[7] = StringMid($TLOG, 25, 1) $record[8] = StringMid($TLOG, 26, 2) $record[9] = StringMid($TLOG, 28, 10) $record[10] = StringMid($TLOG, 38, 1) If $record[2] = "1" Then $record_parsed[2] = "Voided" Else $record_parsed[2] = "Not Voided" EndIf $record_parsed[4] = Call("Dollar", $record[4]) Switch $record[5] Case "0" $record_parsed[5] = "Positive" Case "1" $record_parsed[5] = "Negative" Case "2" $record_parsed[5] = "Non Refundable Fee" EndSwitch Switch $record[6] Case "1" $record_parsed[6] = "Transaction-based" Case "0" $record_parsed[6] = "Item-based" EndSwitch Switch $record[7] Case "1" $record_parsed[7] = "Fee is returanble" Case "0" $record_parsed[7] = "Fee is not returnable" EndSwitch Switch $record[8] Case "1" $record_parsed[8] = "Amount-based" Case "0" $record_parsed[8] = "Percentage-based" EndSwitch $Label[1] = "Identifier" $Label[2] = "Void Indicator" $Label[3] = "Fee Code" $Label[4] = "Amount" $Label[5] = "Status Indicator" $Label[6] = "Fee Type Indicator" $Label[7] = "Return Indicator" $Label[8] = "Fee Calculation Type" $Label[9] = "Fee Value" $Label[10] = "Send Fee" EndFunc ;==>REC004 Thanks in advance for any help on this. plkace this text 0010048150 0000500730000010000000000399000000039900000003990000000000010000000399010000000000000 0010048627 0000500730000010000000000399000000039900000003990000000000010000000399011000000000000 0010047109 0000500730000010000000000399000000039900000003990000000000010000000399011000000000000 in a file named tlog.new in c:\ts\ or edit the variable line to place the file wherever you want. Edited April 30 by goodmanjl531 add more detail on data source
pixelsearch Posted April 30 Posted April 30 (edited) Just an idea, in all these lines found in your script... ControlSetText("", "", ...) ...shouldn't the 1st parameter be the GUI handle ? For example ControlSetText($Form_record, "", $Btn_Next, "Next Record") instead of ControlSetText("", "", $Btn_Next, "Next Record") But I'm not sure it will solve it, as you never use ControlSetText on $Btn_Prev and it disappears randomly too, as shown in your 2nd pic. You could also try to comment out the line where you ControlSetText() $Btn_Next, especially you keep the same text for the button, so what's the use of ControlSetText in this case ? If you comment out the line where you ControlSetText() $Btn_Next, then if the button text doesn't turn blank randomly when you run your code, now you'll be 100% sure the issue comes from this line. If all this doesn't work, maybe you could share some data ($sFile_tlog_path) so we could try the code, without the error encountered now : Subscript used on non-accessible variable.: $tempRec = $TlogArray[$row] $tempRec = $TlogArray^ ERROR Edited April 30 by pixelsearch typo "I think you are searching a bug where there is no bug... don't listen to bad advice."
pixelsearch Posted April 30 Posted April 30 (edited) A test I just did, maybe it will be some help. As we don't have the file "C:\TS\tlog.new" then let's create a minimal array, to make the script runnable ; Global $sFile_tlog_path = "C:\TS\tlog.new" ; _FileReadToArray($sFile_tlog_path, $TlogArray) ; Read TLOG file and add to an array to be able to read line by line Global $TlogArray = ["a", "b"] After we close MsgBox, we enter function Update_Form 1) With original code (For $ind = 1 To 25) 2) With this code (For $ind = 1 To 24) The "Exit" text always disappears (by my side) when the loop goes From 1 To 25 The "Exit" text always shows (by my side) when the loop goes From 1 To 24 For what it's worth... Edit: the "Exit" text always disappears too, when the loop goes From 0 To 24 (just tested) Edited April 30 by pixelsearch added test on loop From 0 To 24 "I think you are searching a bug where there is no bug... don't listen to bad advice."
Solution pixelsearch Posted April 30 Solution Posted April 30 (edited) First of all, the pics in my preceding post correspond to this order of controls creation : ; my order of controls creation $Btn_Exit = GUICtrlCreateButton("Exit", 232, 736 - 40, 209, 33) $Btn_Prev = GUICtrlCreateButton("Previous Record", 499, 736 - 40, 209, 33) $Label7 = GUICtrlCreateLabel("Record#", 776, 736 - 40, 166, 25) $Btn_Next = GUICtrlCreateButton("Next Record", 1072, 736 - 40, 209, 33) ; OP's order of controls creation ; $Btn_Prev = GUICtrlCreateButton("Previous Record", 499, 737, 209, 33) ; $Btn_Exit = GUICtrlCreateButton("Exit", 232, 736, 209, 33) ; $Btn_Next = GUICtrlCreateButton("Next Record", 1072, 736, 209, 33) ; $Label7 = GUICtrlCreateLabel("Record#", 776, 736, 166, 25) This explains why it's the Exit button that loses his text in the pics (on OP's side it should be $Btn_Prev) Let's stick to my order of creation : if we add this line after $Btn_Exit creation, we would see : ConsoleWrite("$Btn_Exit = " & $Btn_Exit & @crlf) ; 84 During Update_Form(), let's add a ConsoleWrite : For $ind = 1 To 25 ControlSetText("", "", $GUI_LBL[$ind], $Label[$ind]) ControlSetText("", "", $GUI_input[$ind], $record[$ind]) ControlSetText("", "", $GUI_input_parsed[$ind], $record_parsed[$ind]) ConsoleWrite($ind & " " & $GUI_LBL[$ind] & " " & $GUI_input[$ind] & " " & $GUI_input_parsed[$ind] & @crlf) Next Now we run the script using my little array ["a", "b"] to make the script runnable, this is the Console display : $Btn_Exit = 84 1 4 13 22 2 5 14 23 3 6 15 24 4 7 16 25 5 8 17 26 6 9 18 27 7 10 19 28 8 11 20 29 9 31 40 49 10 32 41 50 11 33 42 51 12 34 43 52 13 35 44 53 14 36 45 54 15 37 46 55 16 38 47 56 17 58 67 76 18 59 68 77 19 60 69 78 20 61 70 79 21 62 71 80 22 63 72 81 23 64 73 82 24 65 74 83 25 We note that there are no GUI id's when $ind reaches 25 in the loop ! Because when you created the GUI, you created controls until 24 (not 25), these are the last ones you created : $GUI_LBL[24] = ... ; id 65 $GUI_input[24] = ... ; id 74 $GUI_input_parsed[24] = ... ; id 83 Which means when $ind reaches 25 in the loop, AutoIt will try to do this : ControlSetText("", "", $GUI_input_parsed[25], $record_parsed[25]) ConsoleWrite("$GUI_input_parsed[25] = " & $GUI_input_parsed[25] & @crlf) ; 0 equivalent to ControlSetText("", "", 0, $record_parsed[25]) ConsoleWrite((GUICtrlRead($Btn_Exit) = " ") & @crlf) ; it's not blank, it's one space, e.g. $record_parsed[25] 0 as id control creates a mess, maybe it uses the control id just after the last updated (?) id 83 = $GUI_input_parsed[24] id 84 = $Btn_Exit (with my order of controls creation) This could explain why you got blank texts in some of your buttons, e.g. the fact that your $ind loop reaches 25, while in your GUI, you created controls until 24 (not 25) Good luck Edited April 30 by pixelsearch typo Musashi 1 "I think you are searching a bug where there is no bug... don't listen to bad advice."
goodmanjl531 Posted May 1 Author Posted May 1 @pixelsearch That was it, not sure why i was going to 25 on my loop when i had 24 of each but thanks so much for helping to catch this. pixelsearch 1
pixelsearch Posted May 1 Posted May 1 (edited) You're welcome, glad it's solved On 4/30/2025 at 7:44 PM, pixelsearch said: Edit: the "Exit" text always disappears too, when the loop goes From 0 To 24 (just tested) This was still intriguing... Q: Why a loop from 0 To 24 makes the button text disappear, even if we don't reach 25 in the loop ? A: The button text disappears when $ind = 0 because $GUI_LBL[0] = 0, this time the button text disappears at the very start of the loop ! On 4/30/2025 at 10:20 PM, pixelsearch said: 0 as id control creates a mess, maybe it uses the control id just after the last updated (?) No, it doesn't use the control id just after the last updated, an example with this script... #include <GUIConstantsEx.au3> Example() Func Example() Local $hGUI = GUICreate("Close GUI to blank the focused button", 450, 300) Local $idButton1 = GUICtrlCreateButton("Button1", 10, 10, 80, 30) ; id 3 (first control created in GUI is always 3) Local $idButton2 = GUICtrlCreateButton("Button2", 10, 50, 80, 30) ; id 4 Local $idButton3 = GUICtrlCreateButton("Button3", 10, 90, 80, 30) ; id 5 GuiCtrlSetSTate($idButton2, $GUI_FOCUS) ; <========== GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ControlSetText($hGUI, "", 0, "") ; id 0 sets text on the focused button Sleep(3000) ExitLoop EndSwitch WEnd GUIDelete($hGUI) EndFunc ;==>Example This test shows that id 0 updates the control that got the focus (in OP's script it can be any button in the GUI) End of test Edit: @ioa747 indicates below that ControlSetText() should not be used with GUI controls, it is GUICtrlSetData() that should be used with GUI controls. Also, please do not use id 0 if you want to avoid issues Edited May 2 by pixelsearch the GUICtrlSetData comment "I think you are searching a bug where there is no bug... don't listen to bad advice."
ioa747 Posted May 2 Posted May 2 ; Another reason why the GUI may not be updating correctly is that you are using ControlSetText("", "", $Btn_Exit, "Exit") ; instead of GUICtrlSetData($Btn_Exit, "Exit") ; to update it. I know that I know nothing
pixelsearch Posted May 2 Posted May 2 Hello @ioa747 I just tested your suggestion with OP's original script, but it didn't work for me (button 'Previous Record' turns blank) Func Update_Form($RecordName, $record, $record_parsed, $Label) ... ; ControlSetText("", "", $Label7, "Record " & $row & " of " & $MaxRecords) ; ControlSetText("", "", $Btn_Exit, "Exit") ; ControlSetText("", "", $Btn_Next, "Next Record") GUICtrlSetData($Label7, "Record " & $row & " of " & $MaxRecords) GUICtrlSetData($Btn_Exit, "Exit") GUICtrlSetData($Btn_Next, "Next Record") GUICtrlSetData($Btn_Prev, "Previous Record") ... EndFunc ;==>Update_Form Did it work by your side ? "I think you are searching a bug where there is no bug... don't listen to bad advice."
ioa747 Posted May 2 Posted May 2 strange to me at first, after calling Update_Form button 'Previous Record' turns blank but after updating Update_Form, it remains as it is Func Update_Form($RecordName, $record, $record_parsed, $Label) WinSetTitle($Form_record, "", $RecordName) GUICtrlSetData($Label7, "Record " & $row & " of " & $MaxRecords) GUICtrlSetData($GUI_input_parsed[1], $RecordName) For $ind = 1 To 25 GUICtrlSetData($GUI_LBL[$ind], $Label[$ind]) GUICtrlSetData($GUI_input[$ind], $record[$ind]) GUICtrlSetData($GUI_input_parsed[$ind], $record_parsed[$ind]) Next EndFunc ;==>Update_Form pixelsearch 1 I know that I know nothing
pixelsearch Posted May 2 Posted May 2 Well done @ioa747 This shows why GUI controls should always use the GUI control update functions, when external controls (outside of AutoIt GUI's) should use the Windows management control functions ( @Melba23 wrote this at least a couple of times, I don't remember where) Still, OP got an issue in his script that he'll fix for sure, as there are no control id's [25] in the GUI (all controls are created from [1] to [24] in each array), these arrays being declared of course with [26] elements or a fatal error would have occured during the loop 1 To 25 (when 25 is reached) So it seems that GUICtrlSetData(0, $record_parsed[25]) doesn't create any visible issue (0 is the value of $GUI_input_parsed[25]) ... ... while ControlSetText($Form_record, "", 0, $record_parsed[25]) updates randomly a control (a GUI focused button for example) How strange. If OP had used GUICtrlSetData() in the first place, he would never notice that something was going wrong in his script. The fact that he used ControlSetText() created random issues (blank buttons) which helped to find the issue (25 instead of 24) Have a great day ioa747 1 "I think you are searching a bug where there is no bug... don't listen to bad advice."
goodmanjl531 Posted May 2 Author Posted May 2 I fixed my loop only going to 24 and only update the labels no need to update the buttons as they never change. and cleaned up my updates to make sure i call the (only) form im using to avoid anything getting weird. Func Update_Form($RecordName, $record, $record_parsed, $Label) WinSetTitle($Form_record, "", $RecordName) ControlSetText($Form_record, "", $GUI_input_parsed[1], $RecordName) ControlSetText($Form_record, "", $Lbl_Record, "Record " & $row & " of " & $MaxRecords) For $ind = 1 To 24 ControlSetText($Form_record, "", $GUI_LBL[$ind], $Label[$ind]) ControlSetText($Form_record, "", $GUI_input[$ind], $record[$ind]) ControlSetText($Form_record, "", $GUI_input_parsed[$ind], $record_parsed[$ind]) Next ControlSetText($Form_record, "", $GUI_input_parsed[1], $RecordName) ControlFocus($Form_record, "", $Btn_Next) EndFunc ;==>Update_Form above is what i am using without isssue. I also tried your advice with guictrlsetdata and it works as well ( When searching for how to update I found the ControlSetText first and it worked.) Func Update_Form($RecordName, $record, $record_parsed, $Label) WinSetTitle($Form_record, "", $RecordName) GUICtrlSetData($GUI_input_parsed[1], $RecordName) GUICtrlSetData($Lbl_Record, "Record " & $row & " of " & $MaxRecords) For $ind = 1 To 24 GUICtrlSetData( $GUI_LBL[$ind], $Label[$ind]) GUICtrlSetData($GUI_input[$ind], $record[$ind]) GUICtrlSetData( $GUI_input_parsed[$ind], $record_parsed[$ind]) Next GUICtrlSetData( $GUI_input_parsed[1], $RecordName) ControlFocus($Form_record, "", $Btn_Next) EndFunc ;==>Update_Form Thanks again to all for their advice and help on this. I'm thinking i went with 25 at first thinking as an array starts with 0 as first record messed me up but i dont use first array record [0] .....
ioa747 Posted May 3 Posted May 3 Food for thought expandcollapse popup; https://www.autoitscript.com/forum/topic/212867-gui-button-text-disapearing/#findComment-1543058 #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 6 -w 7 #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <Array.au3> #include <MsgBoxConstants.au3> ; folding with _ (makes it more readable) *** Global $Form_record, $MaxRecords, $Form_Main, $Btn_Exit, $Btn_Next, $Btn_Prev, $record[26], $record_parsed[26], $Label7, _ $Label[26], $GUI_LBL[26], $GUI_input[26], $GUI_input_parsed[26], $TlogArray, $RecordName, $row, $tempRec, $rectype, $nMsg, _ $sFile_tlog_path = @ScriptDir & "\tlog.new" ; "C:\TS\tlog.new" _FileReadToArray($sFile_tlog_path, $TlogArray) ; Read TLOG file and add to an array to be able to read line by line ;~ $Totalrows = UBound($TlogArray) ; You don't use it anywhere else. *** $MaxRecords = $TlogArray[0] ; $Totalrows - 1 ; *** For $ind = 1 To 25 $record[$ind] = " " $record_parsed[$ind] = " " $Label[$ind] = " " Next $RecordName = "TLOG Decoder" Build_Form($RecordName, $record, $record_parsed, $Label) ;~ Call("Build_Form", $RecordName, $record, $record_parsed, $Label) ; *** ;~ GUISetState(@SW_SHOW, $Form_record) ; I moved it into Build_Form() ; *** Sleep(1000) $row = 1 Do $tempRec = $TlogArray[$row] $rectype = StringLeft($tempRec, 3) Select Case $rectype = "001" $RecordName = "String Type 001 - Merchandise Item" REC001($tempRec) ;~ Call("REC001", $tempRec) ; *** Case $rectype = "004" $RecordName = "String Type 004 - Fee" REC004($tempRec) ;~ Call("REC004", $tempRec) ; *** Case Else ; NON Coded response MsgBox(0, "Claires TLOG DECODER - JLG", "Code " & $rectype & " Not found") EndSelect Update_Form($RecordName, $record, $record_parsed, $Label) ;~ Call("Update_Form", $RecordName, $record, $record_parsed, $Label) ; *** While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $Btn_Exit GUIDelete($Form_record) Exit ;~ Case $Btn_Exit ; I updated it above. *** ;~ GUIDelete($Form_record) ;~ Exit Case $Btn_Next If $row = $MaxRecords Then MsgBox(0, "TLOG Decoder", "Last Record Nothing After") ContinueLoop EndIf $row += 1 ExitLoop Case $Btn_Prev If $row = 1 Then MsgBox(0, "TLOG Decoder", "First record nothing prior") ContinueLoop EndIf $row -= 1 ExitLoop EndSwitch WEnd ;~ I moved it above so you don't have to reread all the data. ; *** ;~ If $row > $MaxRecords Then ;~ MsgBox(0, "TLOG Decoder", "Last Record Nothing After") ;~ $row -= 1 ;~ EndIf ;~ If $row < 1 Then ;~ MsgBox(0, "TLOG Decoder", "First record nothing prior") ;~ $row = 1 ;~ EndIf Until $row > $MaxRecords Exit ; **** END OF MAIN PROGRAM **** ;--------------------------------------------------------------------------------------- Func Dollar($record) Return ("$ " & StringFormat("%.2f", $record / 100)) EndFunc ;==>Dollar ;--------------------------------------------------------------------------------------- Func ConvertToDate($record) Return (StringTrimRight($record, 6) & "/" & StringMid($record, 3, 2) & "/" & StringTrimLeft($record, 4)) EndFunc ;==>ConvertToDate ;--------------------------------------------------------------------------------------- Func ConvertToPercentage($record) Return (StringFormat("%.5f,", $record / 100000) & " %") EndFunc ;==>ConvertToPercentage ;--------------------------------------------------------------------------------------- Func ConvertToXDecimals($record, $Precision) Local $mult, $newnumb Switch $Precision Case 1 $mult = 10 $newnumb = (StringFormat("%.1f", $record / $mult)) Case 2 $mult = 100 $newnumb = (StringFormat("%.2f", $record / $mult)) Case 3 $mult = 1000 $newnumb = (StringFormat("%.3f", $record / $mult)) Case 4 $mult = 10000 $newnumb = (StringFormat("%.4f", $record / $mult)) Case 5 $mult = 100000 $newnumb = (StringFormat("%.5f", $record / $mult)) Case 6 $mult = 1000000 $newnumb = (StringFormat("%.6f", $record / $mult)) EndSwitch Return $newnumb EndFunc ;==>ConvertToXDecimals ;--------------------------------------------------------------------------------------- Func Sign($record) Return ($record = "0" ? "Positive" : "Negative") ;~ If $record = "0" Then ; *** ;~ Return "Positive" ;~ Else ;~ Return "Negative" ;~ EndIf EndFunc ;==>Sign ;--------------------------------------------------------------------------------------- Func Build_Form($RecordName, $record, $record_parsed, $Label) ;--> Build form For $ind = 1 To 25 $record[$ind] = " " $record_parsed[$ind] = " " $Label[$ind] = " " Next $Form_record = GUICreate("TLOG DECODER 101 - JLG", 1515, 798, 228, 88) Local $idx, $X = 25, $Y = 50 For $i = 1 To 3 For $j = 1 To 8 $idx += 1 $GUI_LBL[$idx] = GUICtrlCreateLabel($idx, $X, $Y, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input[$idx] = GUICtrlCreateLabel($idx, $X + 155, $Y, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input_parsed[$idx] = GUICtrlCreateLabel($idx, $X + 310, $Y, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $Y += 70 Next GUICtrlCreateLabel("Description", $X, 20, 145, 21, $SS_CENTER) GUICtrlCreateLabel("RAW", $X + 155, 20, 145, 21, $SS_CENTER) GUICtrlCreateLabel("PARSED", $X + 310, 20, 145, 21, $SS_CENTER) If $i < 3 Then $X += 500 $Y = 50 ;ConsoleWrite("X=" & $X & @CRLF) EndIf Next $idx += 1 ; the forgotten 25 $GUI_LBL[$idx] = GUICtrlCreateLabel($idx, $X, $Y, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input[$idx] = GUICtrlCreateLabel($idx, $X + 155, $Y, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) $GUI_input_parsed[$idx] = GUICtrlCreateLabel($idx, $X + 310, $Y, 145, 49) GUICtrlSetBkColor(-1, 0xFFFFFF) #Region ; old *** ;~ GUICtrlCreateLabel("Description", 24, 8, 145, 21, $SS_CENTER) ;~ $GUI_LBL[1] = GUICtrlCreateLabel("1", 24, 50, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_LBL[2] = GUICtrlCreateLabel("2", 24, 126, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_LBL[3] = GUICtrlCreateLabel("3", 24, 203, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_LBL[4] = GUICtrlCreateLabel("4", 24, 281, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_LBL[5] = GUICtrlCreateLabel("5", 24, 358, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_LBL[6] = GUICtrlCreateLabel("6", 24, 436, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_LBL[7] = GUICtrlCreateLabel("7", 24, 513, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_LBL[8] = GUICtrlCreateLabel("8", 24, 591, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ GUICtrlCreateLabel("RAW", 175, 8, 145, 21, $SS_CENTER) ;~ $GUI_input[1] = GUICtrlCreateLabel("9", 175, 50, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input[2] = GUICtrlCreateLabel("10", 175, 126, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input[3] = GUICtrlCreateLabel("11", 175, 203, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input[4] = GUICtrlCreateLabel("12", 175, 281, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input[5] = GUICtrlCreateLabel("13", 175, 358, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input[6] = GUICtrlCreateLabel("14", 175, 436, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input[7] = GUICtrlCreateLabel("15", 175, 513, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input[8] = GUICtrlCreateLabel("16", 175, 591, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ GUICtrlCreateLabel("PARSED", 329, 8, 145, 21, $SS_CENTER) ;~ $GUI_input_parsed[1] = GUICtrlCreateLabel("17", 329, 50, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input_parsed[2] = GUICtrlCreateLabel("18", 329, 126, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input_parsed[3] = GUICtrlCreateLabel("19", 329, 203, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input_parsed[4] = GUICtrlCreateLabel("20", 329, 281, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input_parsed[5] = GUICtrlCreateLabel("21", 329, 358, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input_parsed[6] = GUICtrlCreateLabel("22", 329, 436, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input_parsed[7] = GUICtrlCreateLabel("23", 329, 513, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input_parsed[8] = GUICtrlCreateLabel("24", 329, 591, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ GUICtrlCreateLabel("Description", 538, 17, 114, 21, $SS_CENTER) ;~ $GUI_LBL[9] = GUICtrlCreateLabel("25", 538, 50, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_LBL[10] = GUICtrlCreateLabel("26", 538, 126, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_LBL[11] = GUICtrlCreateLabel("27", 538, 203, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_LBL[12] = GUICtrlCreateLabel("28", 538, 281, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_LBL[13] = GUICtrlCreateLabel("29", 538, 358, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_LBL[14] = GUICtrlCreateLabel("30", 538, 436, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_LBL[15] = GUICtrlCreateLabel("31", 538, 513, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_LBL[16] = GUICtrlCreateLabel("32", 538, 591, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ GUICtrlCreateLabel("RAW", 690, 17, 145, 21, $SS_CENTER) ;~ $GUI_input[9] = GUICtrlCreateLabel("33", 690, 50, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input[10] = GUICtrlCreateLabel("34", 690, 126, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input[11] = GUICtrlCreateLabel("35", 690, 203, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input[12] = GUICtrlCreateLabel("36", 690, 281, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input[13] = GUICtrlCreateLabel("37", 690, 358, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input[14] = GUICtrlCreateLabel("38", 690, 436, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input[15] = GUICtrlCreateLabel("39", 690, 513, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input[16] = GUICtrlCreateLabel("40", 690, 591, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ GUICtrlCreateLabel("PARSED", 845, 17, 145, 21, $SS_CENTER) ;~ $GUI_input_parsed[9] = GUICtrlCreateLabel("41", 845, 50, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input_parsed[10] = GUICtrlCreateLabel("42", 845, 126, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input_parsed[11] = GUICtrlCreateLabel("43", 845, 203, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input_parsed[12] = GUICtrlCreateLabel("44", 845, 281, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input_parsed[13] = GUICtrlCreateLabel("45", 845, 358, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input_parsed[14] = GUICtrlCreateLabel("46", 845, 436, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input_parsed[15] = GUICtrlCreateLabel("47", 845, 513, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input_parsed[16] = GUICtrlCreateLabel("48", 845, 591, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ GUICtrlCreateLabel("Description", 1045, 17, 114, 21, $SS_CENTER) ;~ $GUI_LBL[17] = GUICtrlCreateLabel("49", 1045, 50, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_LBL[18] = GUICtrlCreateLabel("50", 1045, 126, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_LBL[19] = GUICtrlCreateLabel("51", 1045, 203, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_LBL[20] = GUICtrlCreateLabel("52", 1045, 281, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_LBL[21] = GUICtrlCreateLabel("53", 1045, 358, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_LBL[22] = GUICtrlCreateLabel("54", 1045, 436, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_LBL[23] = GUICtrlCreateLabel("55", 1045, 513, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_LBL[24] = GUICtrlCreateLabel("56", 1045, 591, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ GUICtrlCreateLabel("RAW", 1199, 17, 145, 21, $SS_CENTER) ;~ $GUI_input[17] = GUICtrlCreateLabel("57", 1199, 50, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input[18] = GUICtrlCreateLabel("58", 1199, 126, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input[19] = GUICtrlCreateLabel("59", 1199, 203, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input[20] = GUICtrlCreateLabel("60", 1199, 281, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input[21] = GUICtrlCreateLabel("61", 1199, 358, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input[22] = GUICtrlCreateLabel("62", 1199, 436, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input[23] = GUICtrlCreateLabel("63", 1199, 513, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input[24] = GUICtrlCreateLabel("64", 1199, 591, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ GUICtrlCreateLabel("PARSED", 1355, 17, 145, 21, $SS_CENTER) ;~ $GUI_input_parsed[17] = GUICtrlCreateLabel("65", 1355, 50, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input_parsed[18] = GUICtrlCreateLabel("66", 1355, 126, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input_parsed[19] = GUICtrlCreateLabel("67", 1355, 203, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input_parsed[20] = GUICtrlCreateLabel("68", 1355, 281, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input_parsed[21] = GUICtrlCreateLabel("69", 1355, 358, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input_parsed[22] = GUICtrlCreateLabel("70", 1355, 436, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input_parsed[23] = GUICtrlCreateLabel("71", 1355, 513, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) ;~ $GUI_input_parsed[24] = GUICtrlCreateLabel("72", 1355, 591, 145, 49) ;~ GUICtrlSetBkColor(-1, 0xFFFFFF) #EndRegion ; old $Btn_Prev = GUICtrlCreateButton("Previous Record", 499, 737, 209, 33) $Btn_Exit = GUICtrlCreateButton("Exit", 232, 736, 209, 33) $Btn_Next = GUICtrlCreateButton("Next Record", 1072, 736, 209, 33) $Label7 = GUICtrlCreateLabel("Record#", 776, 736, 166, 25) GUISetState(@SW_SHOW, $Form_record) EndFunc ;==>Build_Form ;--------------------------------------------------------------------------------------- Func Update_Form($RecordName, $record, $record_parsed, $Label) WinSetTitle($Form_record, "", $RecordName) GUICtrlSetData($Label7, "Record " & $row & " of " & $MaxRecords) GUICtrlSetData($GUI_input_parsed[1], $RecordName) For $ind = 1 To 25 GUICtrlSetData($GUI_LBL[$ind], $Label[$ind]) GUICtrlSetData($GUI_input[$ind], $record[$ind]) GUICtrlSetData($GUI_input_parsed[$ind], $record_parsed[$ind]) Next EndFunc ;==>Update_Form ;--------------------------------------------------------------------------------------- Func REC001($TLOG) ;String type001 Merhcandise Item For $ind = 1 To 25 $record[$ind] = " " $record_parsed[$ind] = " " ;~ $Label[$ind] = "Not Used" ; no need ?? *** Next $record[1] = StringMid($TLOG, 1, 3) $record[2] = StringMid($TLOG, 4, 1) $record_parsed[2] = ($record[2] ? "Voided" : "Not Voided") ;~ If $record[2] = "1" Then ; *** ;~ $record_parsed[2] = "Voided" ;~ Else ;~ $record_parsed[2] = "Not Voided" ;~ EndIf $record[3] = StringMid($TLOG, 5, 1) $record_parsed[3] = ($record[3] ? "Exchanged" : "Not Exchanged") ;~ If $record[3] = "1" Then ; *** ;~ $record_parsed[3] = "Exchanged" ;~ Else ;~ $record_parsed[3] = "Not Exchanged" ;~ EndIf $record[4] = StringMid($TLOG, 6, 24) $record[5] = StringMid($TLOG, 30, 1) $record_parsed[5] = ($record[5] ? "Class" : "SKU") ;~ If $record[5] = "1" Then ; *** ;~ $record_parsed[5] = "Class" ;~ Else ;~ $record_parsed[5] = "SKU" ;~ EndIf $record[6] = StringMid($TLOG, 31, 4) $record[7] = StringMid($TLOG, 35, 4) $record[8] = StringMid($TLOG, 39, 9) ;$record_parsed[8] = $record[8] / 1000 $record_parsed[8] = ConvertToXDecimals($record[8], 3) ; Call("ConvertToXDecimals", $record[8], 3) ; *** $record[9] = StringMid($TLOG, 48, 10) $record_parsed[9] = Dollar($record[9]) ; Call("Dollar", $record[9]) ; *** $record[10] = StringMid($TLOG, 58, 10) $record_parsed[10] = Dollar($record[10]) ; Call("Dollar", $record[10]) ; *** $record[11] = StringMid($TLOG, 68, 10) $record_parsed[11] = Dollar($record[11]) ; Call("Dollar", $record[11]) ; *** $record[12] = StringMid($TLOG, 78, 10) $record[13] = StringMid($TLOG, 88, 2) $record[14] = StringMid($TLOG, 90, 10) $record_parsed[14] = Dollar($record[14]) ; Call("Dollar", $record[14]) ; *** $record[15] = StringMid($TLOG, 100, 1) $record[16] = StringMid($TLOG, 101, 1) $record[17] = StringMid($TLOG, 102, 1) $record[18] = StringMid($TLOG, 103, 2) $record[19] = StringMid($TLOG, 105, 1) $record[20] = StringMid($TLOG, 106, 1) $record[21] = StringMid($TLOG, 107, 1) $record[22] = StringMid($TLOG, 108, 1) $record[23] = StringMid($TLOG, 109, 2) $record[24] = StringMid($TLOG, 111, 1) $record[25] = StringMid($TLOG, 112, 3) $Label[1] = "Identifier" $Label[2] = "Void Indicator" $Label[3] = "Exchange Indicator" $Label[4] = "Item Number" $Label[5] = "Sku/Class Indicator" $Label[6] = "Department Number" $Label[7] = "Class Number" $Label[8] = "Quantity" $Label[9] = "Price Original" $Label[10] = "Price On Lookup" $Label[11] = "Price Before Discount" $Label[12] = "Reserved for Future" $Label[13] = "Price Indicator" $Label[14] = "Extended Total" $Label[15] = "Not On File" $Label[16] = "Entry Indicator" $Label[17] = "Taxable Indicator " $Label[18] = "Item Status" $Label[19] = "Raincheck " $Label[20] = "Gift Item" $Label[21] = "Package" $Label[22] = "Send Item Indicator" $Label[23] = "Send to Location" $Label[24] = "Team Associate Item" $Label[25] = "Team Number" EndFunc ;==>REC001 ;--------------------------------------------------------------------------------------- Func REC004($TLOG) ; StringType:004 Fee For $ind = 1 To 25 $record[$ind] = " " $record_parsed[$ind] = " " $Label[$ind] = "Not Used" Next $record[1] = StringMid($TLOG, 1, 3) $record[2] = StringMid($TLOG, 4, 1) $record[3] = StringMid($TLOG, 5, 8) $record[4] = StringMid($TLOG, 13, 10) $record[5] = StringMid($TLOG, 23, 1) $record[6] = StringMid($TLOG, 24, 1) $record[7] = StringMid($TLOG, 25, 1) $record[8] = StringMid($TLOG, 26, 2) $record[9] = StringMid($TLOG, 28, 10) $record[10] = StringMid($TLOG, 38, 1) $record_parsed[2] = $record[2] = "1" ? "Voided" : "Not Voided" ;~ If $record[2] = "1" Then ; *** ;~ $record_parsed[2] = "Voided" ;~ Else ;~ $record_parsed[2] = "Not Voided" ;~ EndIf $record_parsed[4] = Call("Dollar", $record[4]) Switch $record[5] Case "0" $record_parsed[5] = "Positive" Case "1" $record_parsed[5] = "Negative" Case "2" $record_parsed[5] = "Non Refundable Fee" EndSwitch $record_parsed[6] = $record[6] ? "Transaction-based" : "Item-based" ;~ Switch $record[6] ; *** ;~ Case "1" ;~ $record_parsed[6] = "Transaction-based" ;~ Case "0" ;~ $record_parsed[6] = "Item-based" ;~ EndSwitch $record_parsed[7] = $record[7] ? "Fee is returanble" : "Fee is not returnable" ;~ Switch $record[7] ; *** ;~ Case "1" ;~ $record_parsed[7] = "Fee is returanble" ;~ Case "0" ;~ $record_parsed[7] = "Fee is not returnable" ;~ EndSwitch $record_parsed[8] = ($record[8] ? "Amount-based" : "Percentage-based") ;~ Switch $record[8] ; *** ;~ Case "1" ;~ $record_parsed[8] = "Amount-based" ;~ Case "0" ;~ $record_parsed[8] = "Percentage-based" ;~ EndSwitch $Label[1] = "Identifier" $Label[2] = "Void Indicator" $Label[3] = "Fee Code" $Label[4] = "Amount" $Label[5] = "Status Indicator" $Label[6] = "Fee Type Indicator" $Label[7] = "Return Indicator" $Label[8] = "Fee Calculation Type" $Label[9] = "Fee Value" $Label[10] = "Send Fee" EndFunc ;==>REC004 ;--------------------------------------------------------------------------------------- I know that I know nothing
goodmanjl531 Posted May 5 Author Posted May 5 @ioa747 Nice work on getting rid of excessive code, I did not know about the Ternary code, that removes so much garbage on my simple binary results. Thanks for you input and thanks for bring the missing 25th field.. ioa747 1
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