fett8802 Posted April 11, 2011 Share Posted April 11, 2011 (edited) Howdy all, My question is fairly simple. I wrote a custom build logger function and didn't realize until I was commenting it that, duh, it was going to run every time I ran the .exe file after compiling as well. So, my question is, I want the function to run when both "Going" (F5 in SciTE) and "Compiling" (F7 in SciTE). The function adds the changes to a log file, updates the current build in the log file, and archives the entire script to a folder. The function itself does exactly what I need it to do, I just need to restrict it to ONLY run during compiling events. I couldn't find anything like this in the Help file. Here's the code: ; #FUNCTION# ==================================================================================================================== ; Name...........: _CreateBuild ; Description ...: This function creates a build archive with log and previous build files. Can be a user defined location, or the script location ; Syntax.........: _CreateBuild( [ $ArchiveLocation = @ScriptDir ] ) ; Parameters ....: $ArchiveLocation - [optional] The directory to use for the archive location. Default is @ScriptDir ; Return values .: Nones ; Author ........: Kris Mills <fett8802 at gmail dot com> ; Required.Files.: If used outside of the KrisUDF, must include the KrisUDF - #include <KrisUDF.au3> ; UserCallTip....: _CreateBuild ( [ "archive location" ] ) Creates a build archive with log and previous build files. Can be a user defined location, or the script location. (required: #include <KrisUDF.au3>) ; Modified.......: 4/11/2011 - Created, commented, added a function header ; =============================================================================================================================== Func _CreateBuild($ArchiveLocation = @ScriptDir) Local $BuildChanges, $BuildCurrent, $BuildLog, $BuildName ;Declare the local variables to use in this function If FileExists($ArchiveLocation & "\BuildLog.ini") = 0 Then FileWrite($ArchiveLocation & "\BuildLog.ini","[CurrentBuild]" & @CRLF & "CurrentBuild=0" & @CRLF) ;If the Log file does not exist, create one with build number 0 If FileExists($ArchiveLocation & "\BuildLog.ini") = 1 Then $BuildLog = FileOpen($ArchiveLocation & "\BuildLog.ini",1) ;If the file does exist, open it in Write mode $BuildCurrent = IniRead($ArchiveLocation & "\BuildLog.ini","CurrentBuild","CurrentBuild",0) ;Get the current build number from the INI file $BuildChanges = InputBox("Create New Build", _GetDate() & " - " & @HOUR & ":" & @MIN & @CRLF & @CRLF & "New Build Number: " & $BuildCurrent + 1 & @CRLF & @CRLF & _ ;First line of code prompting the user for change information "Please write a short description of the changes made in this build.","","",200,200) ;Second line of code prompting the user for change information If $BuildChanges = "" Then $BuildChanges = "Changes not noted." ;If the user does not include change information, write "Changes not noted." FileWrite($BuildLog, @CRLF & "===== Build: " & $BuildCurrent + 1 & " - " & _GetDate() & " - " & @HOUR & ":" & @MIN & " =====" & @CRLF & " " & $BuildChanges) ;Write the new build information to the Log file IniWrite($ArchiveLocation & "\BuildLog.ini","CurrentBuild","CurrentBuild",$BuildCurrent + 1) ;Change the current version to the new build number FileClose($BuildLog) ;Close the Log file $BuildName = StringTrimRight(@ScriptName,4) ;Get the script name by removing the file extension from the filename FileCopy(@ScriptFullPath, $ArchiveLocation & "\Builds\" & $BuildName & "_v" & $BuildCurrent + 1 & ".au3",9) ;Copy the script in the Builds folder for archiving EndFunc ;==>_CreateBuild Thanks for your help! - Kris Oh, and if you'd like to run this function, you'll also need this: expandcollapse popup; #FUNCTION# ==================================================================================================================== ; Name...........: _GetDate ; Description ...: Retrieves the current date in the following format: "Monday, March 28, 2011" ; Syntax.........: _GetDate() ; Parameters ....: None ; Return values .: The date in a string formatted as "Monday, March 28, 2011" ; Author ........: Kris Mills <fett8802 at gmail dot com> ; Remarks .......: Uses the internal computer dates ; UserCallTip....: _GetDate ( ) Retrieves the current date in the following format: "Monday, March 28, 2011" (required: #include <KrisUDF.au3>) ; Modified.......: 3/29/2011 - Created, commented, add function header ; =============================================================================================================================== Func _GetDate() Local $sWDay, $sMonth, $sDay ;Declare the local variables for use in this function Select ;Start a Select conditional statement Case @WDAY = 1 ;If the weekday number is 1, then $sWDay = "Sunday" ;Write Sunday to the $sWDay variable Case @WDAY = 2 ;If the weekday number is 2, then $sWDay = "Monday" ;Write Monday to the $sWDay variable Case @WDAY = 3 ;If the weekday number is 3, then $sWDay = "Tuesday" ;Write Tuesday to the $sWDay variable Case @WDAY = 4 ;If the weekday number is 4, then $sWDay = "Wednesday" ;Write Wednesday to the $sWDay variable Case @WDAY = 5 ;If the weekday number is 5, then $sWDay = "Thursday" ;Write Thursday to the $sWDay variable Case @WDAY = 6 ;If the weekday number is 6, then $sWDay = "Friday" ;Write Friday to the $sWDay variable Case @WDAY = 7 ;If the weekday number is 7, then $sWDay = "Saturday" ;Write Saturday to the $sWDay variable EndSelect ;End the day Select conditional statement Select ;Start a Select conditional statement Case @MON = 1 ;If the month number is 1, then $sMonth = "January" ;Write January to the $sMonth variable Case @MON = 2 ;If the month number is 2, then $sMonth = "February" ;Write February to the $sMonth variable Case @MON = 3 ;If the month number is 3, then $sMonth = "March" ;Write March to the $sMonth variable Case @MON = 4 ;If the month number is 4, then $sMonth = "April" ;Write April to the $sMonth variable Case @MON = 5 ;If the month number is 5, then $sMonth = "May" ;Write May to the $sMonth variable Case @MON = 6 ;If the month number is 6, then $sMonth = "June" ;Write June to the $sMonth variable Case @MON = 7 ;If the month number is 7, then $sMonth = "July" ;Write July to the $sMonth variable Case @MON = 8 ;If the month number is 8, then $sMonth = "August" ;Write August to the $sMonth variable Case @MON = 9 ;If the month number is 9, then $sMonth = "September" ;Write September to the $sMonth variable Case @MON = 10 ;If the month number is 10, then $sMonth = "October" ;Write October to the $sMonth variable Case @MON = 11 ;If the month number is 11, then $sMonth = "November" ;Write November to the $sMonth variable Case @MON = 12 ;If the month number is 12, then $sMonth = "December" ;Write December to the $sMonth variable EndSelect ;End the month Select conditional statement $sDay = @MDAY ;Write the @MDAY value to the $sDay variable If @MDAY < 10 Then $sDay = StringTrimLeft(@MDAY,1) ;If the day is less than 10, remove the leading 0 Return $sWDay & ", " & $sMonth & " " & $sDay & ", " & @YEAR ;Return the date string EndFunc ;==>_GetDate Edited April 11, 2011 by fett8802 [sub]My UDF[/sub][sub] - Basics and Time extensions. Great for those new at AutoIt, also contains some powerful time extensions for pros.[/sub][sub]ScrabbleIt[/sub][sub] - Scrabble done in pure AutoIt. (In Progress)[/sub][sub]Nerd Party Extreme | My Portfolio | [email="fett8802@gmail.com"]Contact Me[/email][/sub] Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted April 11, 2011 Share Posted April 11, 2011 There's no code run when compiling. Make a script using that function and call with #AutoIt3Wrapper_Run_Before= / #AutoIt3Wrapper_Run_After= .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 11, 2011 Moderators Share Posted April 11, 2011 fett8802,I do not believe that any code is run when compiling. To distinguish between scripts and compiled exes, just use the @Compiled macro. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
fett8802 Posted April 11, 2011 Author Share Posted April 11, 2011 (edited) fett8802, I do not believe that any code is run when compiling. To distinguish between scripts and compiled exes, just use the @Compiled macro. M23 Thanks for your replies, Alex and Melba. I ended up going with Melba's solution, because I really wanted it to be a function that could be transplanted into any script. Thanks a lot to both of you! I added this line just under the Func line: If @Compiled = 1 Then Return ;Only executes the function if the script is not compiled - Kris Edited April 11, 2011 by fett8802 [sub]My UDF[/sub][sub] - Basics and Time extensions. Great for those new at AutoIt, also contains some powerful time extensions for pros.[/sub][sub]ScrabbleIt[/sub][sub] - Scrabble done in pure AutoIt. (In Progress)[/sub][sub]Nerd Party Extreme | My Portfolio | [email="fett8802@gmail.com"]Contact Me[/email][/sub] Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted April 11, 2011 Share Posted April 11, 2011 (edited) Thanks for your replies, Alex and Melba. I ended up going with Melba's solution, because I really wanted it to be a function that could be transplanted into any script. Thanks a lot to both of you! I added this line just under the Func line: If @Compiled = 1 Then Return ;Only executes the function if the script is not compiled - Kris So you were just joking when you said you wanted it to run once when compiling, not every time the script is launched? Then this thread was pointless. Thank you for that. Edit: Also that's a stupid line of code. But what can you expect from a troll. Edited April 11, 2011 by AdmiralAlkex .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 11, 2011 Moderators Share Posted April 11, 2011 AdmiralAlkex, I do not see the OP as a troll. He wanted to run the function whenever the script was run in SciTE and not when it was compiled - there was a misunderstanding about the compilation process needing to be taken into consideration as well. And for my education - why is that a stupid line of code? I would have done exactly the same thing. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
bogQ Posted April 11, 2011 Share Posted April 11, 2011 I would have done exactly the same thing. I don't believe you. You probably would do it like... If @Compiled Then Return TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 11, 2011 Moderators Share Posted April 11, 2011 bogQ, All right - you have me there! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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