hmsSurprise Posted April 6, 2007 Posted April 6, 2007 Greetings, I want to keep a running log of what my script is doing on the screen, perhaps in a scrollable window that I can post strings to that are prefaced with the output of _NowCalc(). I know I can figure out how to do it with time but if there is a working example I can start with that would be a great leg up in development and time savings. Thanks, jh
Kourath Posted April 6, 2007 Posted April 6, 2007 is this what you had in mind? #include <GUIConstants.au3> #include <Date.au3> Opt("GUIOnEventMode", 1) $Log_GUI = GUICreate("Log", 385, 395, 258, 190) GUISetOnEvent($GUI_EVENT_CLOSE, "Log_Close") $Log_Edit = GUICtrlCreateEdit("", 8, 8, 369, 377, BitOR($ES_AUTOVSCROLL,$ES_READONLY,$ES_WANTRETURN,$WS_VSCROLL)) GUISetState(@SW_SHOW) While 1 Sleep(100) WEnd Func Log_Close() Exit ;could be 'GUISetState(@SW_HIDE, $Log_GUI)' if you do not want to exit the script EndFunc Func _WriteLineToLog($Log_String_WriteLineToLog) GUICtrlSetData($Log_Edit, _NowCalc() & " - " & $Log_String_WriteLineToLog & @CRLF, 1) endfunc you can write to the log by using the function "_WriteLineToLog" in the format of "WriteLineToLog("Any string/string variable here")". Hide the GUI by using "GUISetState(@SW_HIDE, $Log_GUI)"
hmsSurprise Posted April 6, 2007 Author Posted April 6, 2007 Yes, this is most excellent! Many thanks. This fits my idea of code re-use: take good code that someone else has debugged, learn from it, and build on it. BTW, why does _WriteLineToLog start w/ an underscore? Is this some type of convention of which I am not yet aware? jh
Kourath Posted April 6, 2007 Posted April 6, 2007 BTW, why does _WriteLineToLog start w/ an underscore? Is this some type of convention of which I am not yet aware?mostly due to this: User Defined Functions StandardsAll function names must start with an underscore (_). *just a good habit to get into.
hmsSurprise Posted April 8, 2007 Author Posted April 8, 2007 mostly due to this: User Defined Functions Standardsjust a good habit to get into.I assumed that was only for functions that would be submitted to AutoIt3 UDFs. I think I will leave it off so if someone else here has to pick up my work they can tell my functions from those supplied with AutoIt.Just a thought.jh
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