Rurorita Posted October 15, 2021 Posted October 15, 2021 Hi, dont really know where to put it. But i like to suggest a Macro like @FunctionName to Autoit3 that returns the current Function that its executed in. example Func _HelloImAFunc() ConsoleWrite("My Func name is : " & @FunctionName & @CRLF) EndFunc and it would console write: "My Func name is : _HelloImAFunc" I dont know if others see a use in that but i do see atleast one usage. There are maybe more. In my current project https://github.com/OfficialLambdax/_netcode_Core-UDF im utilizing a Tracer that keeps track of every called function. I mainly use that to find bugs, errors and to see how long a function needs in milliseconds so that i can find a bottleneck and do improvements. The Tracer looks like this expandcollapse popup; =================================================================================================================================================== ; Tracer ; enables the Tracer. Will slow down the UDF by about 5 %, but needs to be True if you want to use any of the options below. ; never toggle THIS option in your script or it might hard crash. All others can be toggled anytime. Global $__net_bTraceEnable = True ; will log every call of a UDF function to the console in a ladder format. Will massively decrease the UDF speed because it floods the console. Global $__net_bTraceLogEnable = True ; will log errors and extendeds to the console and their describtions. very usefull while developing Global $__net_bTraceLogErrorEnable = True ; will save all errors, its extendeds and further information to an array. Array can be looked at with _ArrayDisplay() Global $__net_bTraceLogErrorSaveToArray = True ; each and every function becomes a Timer set to it. Once the function is done the Tracer outputs the time it took to finish the function. ; this is mostly a development function to see where things take long and to see what can be improved. Global $__net_bTraceEnableTimers = True ; ======================================================================= ; Tracer dont change Global $__net_arTraceLadder[0][2] ; func name | timer Global $__net_arTraceErrors[0][9] ; date | time | funcname | error code | extended code | error desc | extended desc | additional data | additional data Func __Trace_FuncIn($sFuncName, $p1 = Default, $p2 = Default, $p3 = Default, $p4 = Default, $p5 = Default, $p6 = Default) If Not $__net_bTraceEnable Then Return Local $nArSize = UBound($__net_arTraceLadder) ReDim $__net_arTraceLadder[$nArSize + 1][2] $__net_arTraceLadder[$nArSize][0] = $sFuncName If $__net_bTraceEnableTimers Then $__net_arTraceLadder[$nArSize][1] = TimerInit() __Trace_LogFunc($p1, $p2, $p3, $p4, $p5, $p6) EndFunc ;==>__Trace_FuncIn Func __Trace_FuncOut($sFuncName, $vReturn = False) If Not $__net_bTraceEnable Then Return $vReturn Local $nArSize = UBound($__net_arTraceLadder) ;~ ConsoleWrite($__net_arTraceLadder[$nArSize - 1][0] & @CRLF) If $__net_arTraceLadder[$nArSize - 1][0] <> $sFuncName Then Exit MsgBox(16, "Error", "Trace Error - Exiting" & @CRLF & $__net_arTraceLadder[$nArSize - 1][0] & " <> " & $sFuncName) If $__net_bTraceEnableTimers Then __Trace_LogFunc(Default, Default, Default, Default, Default, Default, TimerDiff($__net_arTraceLadder[$nArSize - 1][1])) ReDim $__net_arTraceLadder[$nArSize - 1][2] Return $vReturn EndFunc ;==>__Trace_FuncOut Func __Trace_Error($nError, $nExtended, $sErrorDescription = "", $sExtendedDescription = "", $vAdditionalData = Null, $vAdditionalData2 = Null) If Not $__net_bTraceEnable Then Return Local $nArSize = UBound($__net_arTraceErrors) If $__net_bTraceLogErrorSaveToArray Then ; date | time | funcname | error code | extended code | error desc | extended desc | additional data | additional data ReDim $__net_arTraceErrors[$nArSize + 1][UBound($__net_arTraceErrors, 2)] $__net_arTraceErrors[$nArSize][0] = @YEAR & "/" & @MON & "/" & @MDAY $__net_arTraceErrors[$nArSize][1] = @HOUR & ":" & @MIN & ":" & @SEC & "." & @MSEC $__net_arTraceErrors[$nArSize][2] = $__net_arTraceLadder[UBound($__net_arTraceLadder) - 1][0] $__net_arTraceErrors[$nArSize][3] = $nError $__net_arTraceErrors[$nArSize][4] = $nExtended $__net_arTraceErrors[$nArSize][5] = $sErrorDescription $__net_arTraceErrors[$nArSize][6] = $sExtendedDescription $__net_arTraceErrors[$nArSize][7] = $vAdditionalData $__net_arTraceErrors[$nArSize][8] = $vAdditionalData2 EndIf __Trace_LogError($nError, $nExtended, $sErrorDescription, $sExtendedDescription) EndFunc ;==>__Trace_Error Func __Trace_LogFunc($p1, $p2, $p3, $p4, $p5, $p6, $nTimerDiff = False) If Not $__net_bTraceLogEnable Then Return Local $sLog = "" Local $nArSize = UBound($__net_arTraceLadder) Local $sEvalParam For $i = 1 To $nArSize - 1 $sLog &= @TAB Next ;~ $sLog &= $__net_arTraceLadder[$nArSize - 1] & "()" $sLog &= $__net_arTraceLadder[$nArSize - 1][0] & "(" For $i = 1 To 6 $sEvalParam = Eval("p" & $i) If $sEvalParam = Default Then If $i <> 1 Then $sLog = StringTrimRight($sLog, 2) ExitLoop EndIf $sLog &= $sEvalParam If $i <> 6 Then $sLog &= ', ' Next $sLog &= ")" If $nTimerDiff Then $sLog &= " Took: " & Round($nTimerDiff, 4) & " ms" ConsoleWrite($sLog & @CRLF) Return ; anti au3check error ; If False = True Then ; __netcode_Au3CheckFix($p1) ; __netcode_Au3CheckFix($p2) ; __netcode_Au3CheckFix($p3) ; __netcode_Au3CheckFix($p4) ; __netcode_Au3CheckFix($p5) ; __netcode_Au3CheckFix($p6) ; EndIf EndFunc ;==>__Trace_LogFunc Func __Trace_LogError($nError, $nExtended, $sErrorDescription, $sExtendedDescription) If Not $__net_bTraceLogErrorEnable Then Return Local $sError = "" Local $nArSize = UBound($__net_arTraceLadder) if Not @Compiled Then $sError &= '! ' If $__net_bTraceLogEnable Then For $i = 1 To $nArSize - 1 $sError &= @TAB Next EndIf ;~ $sError &= $__net_arTraceLadder[$nArSize - 1][0] & "() Err: " & $nError & " - Ext: " & $nExtended & " - '" & $sErrorDescription & "' - '" & $sExtendedDescription & "'" $sError &= $__net_arTraceLadder[$nArSize - 1][0] & "() Err: " & $nError & " - Ext: " & $nExtended if $sErrorDescription <> "" Or $sExtendedDescription <> "" Then $sError &= " -" if $sErrorDescription <> "" Then $sError &= " Err: '" & $sErrorDescription & "'" if $sExtendedDescription <> "" Then $sError &= " Ext: '" & $sExtendedDescription & "'" ConsoleWrite($sError & @CRLF) EndFunc ;==>__Trace_LogError is used like this _HelloImAFunc(0, 10) Func _HelloImAFunc($p1, $p2) __Trace_FuncIn("_HelloImAFunc", $p1, $p2) Local $nCount = $p1 While $nCount < $p2 __Trace_Error(1, $nCount, "$nCount < 10", "$nCount is: " & $nCount) $nCount += 1 WEnd __Trace_FuncOut("_HelloImAFunc") EndFunc in _netcode like this It would definitly be easier to implement a tracer with CTRL+V when i only need to use the macro. Maybe someone else also sees a use in that. Or maybe im just dumb and there is already a easy and fast way to do that. Second thing id like to suggest ist a Command to retrieve the required params for a function. I think about the Call() command which will fail if not enough params are given. It would be nice to have a command where the string name of the function can be given to and it returns the param count. Func _HelloImAFunc() ConsoleWrite("Func _HelloImAlsoAFunc requires : " & Params("_HelloImAlsoAFunc") & " Parameters" & @CRLF) EndFunc Func _HelloImAlsoAFunc($p1, $p2) EndFunc Thoughts? Amateur Coder - UDF's _storageS-UDF , _netcode-UDF (_netcode_Core-UDF, _netcode_AddonCore-UDF, _netcode_Proxy-UDF, _netcode_Relay-UDF, _netcode_Router-UDF)
Earthshine Posted October 15, 2021 Posted October 15, 2021 why don't you just use a logger in your code? My resources are limited. You must ask the right questions
Rurorita Posted October 15, 2021 Author Posted October 15, 2021 2 minutes ago, Earthshine said: why don't you just use a logger in your code? I dont really get what you mean. Isnt that a logger? Amateur Coder - UDF's _storageS-UDF , _netcode-UDF (_netcode_Core-UDF, _netcode_AddonCore-UDF, _netcode_Proxy-UDF, _netcode_Relay-UDF, _netcode_Router-UDF)
Earthshine Posted October 15, 2021 Posted October 15, 2021 (edited) you add logging lines of code to your application. they aren't going to build one in for you.. lol you simply add a line of code to the beginning of your func to announce it's been called. i doubt they are going to go off and turn this into a OOP language that can use reflection... dream on Edited October 15, 2021 by Earthshine My resources are limited. You must ask the right questions
Rurorita Posted October 15, 2021 Author Posted October 15, 2021 5 minutes ago, Earthshine said: you add logging lines of code to your application. they aren't going to build one in for you.. lol you simply add a line of code to the beginning of your func to announce it's been called. i doubt they are going to go off and turn this into a OOP language that can use reflection... dream on Nice UDF, havent seen that before. But to what i read in the describiton it does the same as my variant, even so my variant has much less features. Besides that i already implemented the tracer in _netcode. It just took a while but would have been much faster with some sort of macro, which is my suggestion here. Amateur Coder - UDF's _storageS-UDF , _netcode-UDF (_netcode_Core-UDF, _netcode_AddonCore-UDF, _netcode_Proxy-UDF, _netcode_Relay-UDF, _netcode_Router-UDF)
Earthshine Posted October 15, 2021 Posted October 15, 2021 (edited) so is your project used in gaming? netcode is gamerspeak https://en.wikipedia.org/wiki/Netcode Edited October 15, 2021 by Earthshine My resources are limited. You must ask the right questions
Rurorita Posted October 15, 2021 Author Posted October 15, 2021 (edited) 14 minutes ago, Earthshine said: so is your project used in gaming? Its ment to be used as an alrounder. A UDF on one hand to get things done easy while fast and secure and on the other to have the options to code more complex projects. I just want to create something that can be used in as many situations a possible, where someone doesnt need to search the whole web just to find a UDF with a certain feature or has to recode alot of a UDF so that one or multiple things get possible. So its not specific for gaming, hell if one want to use it for gaming then they can. I personally just did tests with some of the addons in between some game clients and game servers to see how the latency is. 15 minutes ago, Earthshine said: netcode is gamerspeak https://en.wikipedia.org/wiki/Netcode Wasnt intentional, i just didnt come up with a better name and thought _netcode sounded good. Edited October 15, 2021 by Rurorita Amateur Coder - UDF's _storageS-UDF , _netcode-UDF (_netcode_Core-UDF, _netcode_AddonCore-UDF, _netcode_Proxy-UDF, _netcode_Relay-UDF, _netcode_Router-UDF)
Earthshine Posted October 15, 2021 Posted October 15, 2021 sockets are not all so secure as you think. what makes this better than a logger? snooping on sockets and passing all this data around? My resources are limited. You must ask the right questions
Rurorita Posted October 15, 2021 Author Posted October 15, 2021 (edited) 56 minutes ago, Earthshine said: sockets are not all so secure as you think. what makes this better than a logger? snooping on sockets and passing all this data around? "sockets are not all so secure as you think. what makes this better than a logger?" please clarify. what has logging todo with socket secureness? or do you mean logger in terms of that someone has access to the computer or network and can log transmitted data? In later case, if the data is encrypted nicely, like i plan with the implementation of TLS, then how should one be able to identify whats flowing through? Besides that, what has all of that todo with the thread topic? Edited October 15, 2021 by Rurorita Amateur Coder - UDF's _storageS-UDF , _netcode-UDF (_netcode_Core-UDF, _netcode_AddonCore-UDF, _netcode_Proxy-UDF, _netcode_Relay-UDF, _netcode_Router-UDF)
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