morpheuz Posted October 27, 2021 Share Posted October 27, 2021 hello, how can I record how many times a code of the script I wrote has run? sample: if $code = 1 then script script script print "how many runs?" Else Endif I want it to add +1 on it all the time sorry for bad english Link to comment Share on other sites More sharing options...
Solution Subz Posted October 27, 2021 Solution Share Posted October 27, 2021 Depends, do you mean how many times the script has been run or how many times during a single session? If you want to count the number of times a script has run you would have to write it to either registry or to a file for example an ini. Examples: ;~ Example 1 - Script Run Count Global $g_iRunCount = IniRead(@ScriptDir & "\Script.ini", "General", "Count", 1) $g_iRunCount += 1 ;~ Do stuff here ;~ Exiting script IniWrite(@ScriptDir & "\Script.ini", "General", "Count", $g_iRunCount) ;~ Example 2 - Function Count Global $g_iFuncCount = 0 MsgBox(0, "Start Function Count", "Run " & $g_iFuncCount & " times.") For $i = 1 To 10 _Example() Next MsgBox(0, "End Function Count", "Run " & $g_iFuncCount & " times.") Func _Example() $g_iFuncCount += 1 ;~ Do stuff Sleep(100) EndFunc morpheuz 1 Link to comment Share on other sites More sharing options...
morpheuz Posted October 27, 2021 Author Share Posted October 27, 2021 9 minutes ago, Subz said: If you want to count the number of times a script has run you would have to write it to either registry or to a file for example an ini. exactly what i was asking it works thank you Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted October 28, 2021 Moderators Share Posted October 28, 2021 You could also write out to the Event Viewer when your script completes. Good not only for keeping track of the number of times run, but also polling for failures. morpheuz and Earthshine 2 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! 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