Fossil Rock Posted December 25, 2005 Share Posted December 25, 2005 I have a weird problem, when I run the code below it runs as it should but when I uncomment the line below the script it gives me a weird result.NOTE: You need to make the 3 files in the root dir for it to work. Anyone know why?expandcollapse popup#include <GUIConstants.au3> ; Declare and Set variables $Path = "C:\" $FN1 = "Example.log"; UNICODE file $FN2 = "Example.txt"; ANSI file $FN3 = "Log.txt"; DIFF file $UNICODE = $Path & $FN1; Combine path & name $ANSI = $Path & $FN2; Combine path & name $DIFF = $Path & $FN3; Combine path & name $FGT = FileGetTime($UNICODE, 0, 1); Get timestamp of $UNICODE $Var = "" $Var1 = "" $N = "" $T = @MON & "/" & @MDAY & "/" & @YEAR & " - " & @HOUR & ":" & @MIN & ":" & @SEC $CL2 = _FCL($ANSI); Count lines in ANSI file $CL3 = _FCL($DIFF); Count lines in DIFF file $CountDiff = $CL2 - $CL3; Calculate difference in ANSI and DIFF files $StartRead = ($CL2 - $CountDiff) + 1; Calculate point to start reading new data $Text1 = ""; Label data $D = ""; Not used $Date_Time = ""; Label data $Variables = GUICreate("Variables", 316, 399, 656, 57) GUICtrlCreateLabel("$Path", 15, 24, 37, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlCreateLabel("$FN1", 15, 48, 34, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlCreateLabel("$FN2", 15, 72, 34, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlCreateLabel("$FN3", 15, 96, 34, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlCreateLabel("$UNICODE", 15, 120, 67, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlCreateLabel("$ANSI", 15, 144, 40, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlCreateLabel("$DIFF", 15, 168, 38, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlCreateLabel("$FGT", 15, 192, 35, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlCreateLabel("$CL2", 15, 216, 33, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlCreateLabel("$CL3", 15, 240, 200, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlCreateLabel("$StartRead", 15, 288, 68, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlCreateLabel("$Text1", 15, 312, 43, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlCreateLabel("$D", 15, 336, 20, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlCreateLabel("$Var", 15, 360, 30, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlCreateLabel("$CountDiff", 15, 264, 64, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlCreateLabel($Path, 95, 24, 200, 17) GUICtrlCreateLabel($FN1, 95, 48, 200, 17) GUICtrlCreateLabel($FN2, 95, 72, 200, 17) GUICtrlCreateLabel($FN3, 95, 96, 200, 17) GUICtrlCreateLabel($UNICODE, 95, 120, 200, 17) GUICtrlCreateLabel($ANSI, 95, 144, 200, 17) GUICtrlCreateLabel($DIFF, 95, 168, 200, 17) GUICtrlCreateLabel($FGT, 95, 192, 200, 17) GUICtrlCreateLabel($CL2, 95, 216, 200, 17) GUICtrlCreateLabel($CL3, 95, 240, 200, 17) GUICtrlCreateLabel($StartRead, 95, 288, 200, 17) GUICtrlCreateLabel($Text1, 95, 312, 200, 17) GUICtrlCreateLabel("Not used", 95, 336, 200, 17) GUICtrlCreateLabel($Var, 95, 360, 200, 17) GUICtrlCreateLabel($CountDiff, 95, 264, 200, 17) GUICtrlCreateLabel($T, 160, 376, 200, 17) GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;;;;;; EndSelect ; GUICtrlSetData($T, @MON & "/" & @MDAY & "/" & @YEAR & " - " & @HOUR & ":" & @MIN & ":" & @SEC) WEnd Exit Func _FCL(ByRef $Var) $Var1 = FileOpen($Var, 0) $LC = 0 While 1 FileReadLine($Var1) If @error Then ExitLoop $LC = $LC + 1 WEnd FileClose($Var1) Return $LC EndFunc ;==>_FCLUncomment this line and it assigns the $T value to the $CL3 label.; GUICtrlSetData($T, @MON & "/" & @MDAY & "/" & @YEAR & " - " & @HOUR & ":" & @MIN & ":" & @SEC) Agreement is not necessary - thinking for one's self is! Link to comment Share on other sites More sharing options...
themax90 Posted December 25, 2005 Share Posted December 25, 2005 You are trying to set a VARIABLE not a graphic, so it must be $T = @MON & "/" & @MDAY & "/" & @YEAR & " - " & @HOUR & ":" & @MIN & ":" & @SEC) instead of a graphic. $T is the date and time variable, not a label control!!! AutoIt Smith Link to comment Share on other sites More sharing options...
Fossil Rock Posted December 25, 2005 Author Share Posted December 25, 2005 I dont understand what you mean, can you elaborate? Agreement is not necessary - thinking for one's self is! Link to comment Share on other sites More sharing options...
themax90 Posted December 25, 2005 Share Posted December 25, 2005 Please check where you create the label, you do not assign the control to a variable. You must first assign it like so: $Variable = GUICtrlCreateLabel($T, 160, 376, 200, 17) ; Further down $T = @MON & "/" & @MDAY & "/" & @YEAR & " - " & @HOUR & ":" & @MIN & ":" & @SEC) GUICtrlSetData($Variable, $T) Can you understand that? AutoIt Smith Link to comment Share on other sites More sharing options...
Fossil Rock Posted December 25, 2005 Author Share Posted December 25, 2005 Yes, thank you. Can you explain why it put the value in a label ? Seems like if it wasn't right it would error or just do nothing but.... there is no code whatsoever that connects the two. Agreement is not necessary - thinking for one's self is! Link to comment Share on other sites More sharing options...
themax90 Posted December 25, 2005 Share Posted December 25, 2005 (edited) Well when you create a Graphical Control, there is a handle involved called a ControlId. This identifier is the link too anything you wish too do involving that created object. You must assign the returned ControlId too a variable because the ControlId may change everytime you run it. Now in order to set data too a control, you must have the ControlId has refered too by the syntax of GUICtrlSetData. Since you aim too set it too the date and time, the original $T variable holding that information must be updated. Now that you have correct information, and the correct ControlId too link into the control, you can now edit the data too the updated $T variable. It would look the same as this, do not use this code, is it a pointless none functional example: GUICtrlSetData(%ControlId of Object%, %Data%) ; In this case %Data% is the variable $T which is the logical string (@MON & "/" & @MDAY & "/" & @YEAR & " - " & @HOUR & ":" & @MIN & ":" & @SEC) ; You can replace %Data% either with the variable or string. GUICtrlSetData(%ControlId%, @MON & "/" & @MDAY & "/" & @YEAR & " - " & @HOUR & ":" & @MIN & ":" & @SEC)) ; Now that you have the data, you must tell AutoIt what label you wish too change according too the variable as defined when you created the label. GUICtrlSetData($LabelID, @MON & "/" & @MDAY & "/" & @YEAR & " - " & @HOUR & ":" & @MIN & ":" & @SEC)) I hope this helps. However, it put the value because the value cannot be a string but a number and DID infact error too be -1, when -1 is involved in a GUICtrlSetData call it is immediatly the last created control, which happened too be that certain label. So it set the last created control, the label, too the data you wished. AutoIt Smith Edited December 25, 2005 by AutoIt Smith Link to comment Share on other sites More sharing options...
Fossil Rock Posted December 25, 2005 Author Share Posted December 25, 2005 Thank you again, this may be the reason for another anomaly I'm having with a counter returning some strange numbers . Merry Christmas Agreement is not necessary - thinking for one's self is! Link to comment Share on other sites More sharing options...
themax90 Posted December 25, 2005 Share Posted December 25, 2005 No problem, I strive too help!! Merry Christmas! AutoIt Smith 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