xul8tr Posted June 24, 2006 Share Posted June 24, 2006 Is there a way to add a function to the begining of a script so if it is halted it will output the error and line to a text file? Link to comment Share on other sites More sharing options...
Xenobiologist Posted June 24, 2006 Share Posted June 24, 2006 Is there a way to add a function to the begining of a script so if it is halted it will output the error and line to a text file?Hi,what about:#include <File.au3>_FileWriteLog( $sLogPath, $sLogMsg )or TrayIconDebug If enabled shows the current script line in the tray icon tip to help debugging.0 = no debug information (default)1 = show debug So long,Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
xul8tr Posted June 24, 2006 Author Share Posted June 24, 2006 the tray only shows, basically i need to run a batch of scripts and have them output the error if there is any errors and then move on to the next script Link to comment Share on other sites More sharing options...
Xenobiologist Posted June 24, 2006 Share Posted June 24, 2006 the tray only shows, basically i need to run a batch of scripts and have them output the error if there is any errors and then move on to the next scriptHmmh, I think then you have to do it o your own. If @error = ... Then MSgBox or _FileWriteLog and Run(next script) So long,Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
xul8tr Posted June 24, 2006 Author Share Posted June 24, 2006 I'm new to this, are you telling me i'd have to make an @error after every function to do what i want it to do? Anybody else have a better idea? Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 24, 2006 Share Posted June 24, 2006 I'm new to this, are you telling me i'd have to make an @error after every function to do what i want it to do? Anybody else have a better idea? I do a lot of install scripts, and being able to QA what happened afterwards is critical. So I have spent some time thinking along the same lines. Lately I've been working with exhaustive logging to a text file as the script progresses. When things have gone wrong, it is usually very obvious what happened from the log file. Here's how I've done it recently. Get some standard code at the beginning of the script to set up logging: #include <file.au3> $LogFile = @ScriptDir & "\" & @ScriptName & _ & @YEAR & _ & @MON & _ & @DAY & "-" & @HOUR & @MIN & ".log" If Not _FileWriteLog($LogFile, "Initialized script from: " & @ScriptFullPath) Then MsgBox(16, "Error!", "Could not initialize log file! Exiting...") Exit EndIf Then, wherever you want to monitor the status of something, like creating a directory, it looks like this: $NewDir = "C:\MyFuncs\Profiles\" & @ComputerName If FileExists($NewDir & "\") Then _FileWriteLog($LogFile, "Profile already exists at: " & $NewDir) Else If DirCreate($NewDir) Then _FileWriteLog($LogFile, "Successfully created profile folder at: " & $NewDir) Else _FileWriteLog($LogFile, "Error occured creating profile folder at: " & $NewDir) EndIf EndIf The resulting log file tells you exactly how things went, and the automatic date/time stamping of _FileWriteLog() even gives you metrics on how long things are taking. Read the help file. What you need to do is read up in the help file on how status is returned from each function you use. In the above example I know that DirCreate() returns 1 for success and 0 for error. Some functions set @error to something instead or additionaly to provide more detailed errors. How to check results from the function depends on the individual function involved. Read the help file One more thing... read the help file... 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...
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