gcue Posted August 26, 2013 Posted August 26, 2013 (edited) nothing fancy, just something i use to output variable or array or even just used to pause between processes expandcollapse popupFunc Debug($variable1 = "", $variable2 = "", $variable3 = "") ;~ #include <array.au3> ;~ $msg_prompt= 262148 If IsArray($variable1) Then _ArrayDisplay($variable1, "Debug") Else $variable = "" $variable = "Var1: " & $variable1 If $variable = "" Then $variable = $variable2 Else $variable &= @CRLF & "Var2: " & $variable2 EndIf If $variable = "" Then $variable = $variable3 Else $variable &= @CRLF & "Var3: " & $variable3 EndIf $prompt = MsgBox($msg_prompt, "Debug", $variable & @CRLF & @CRLF & "Exit?") If $variable <> "" Then $variable = StringRegExpReplace($variable, "Var[\d]: ", "") ClipPut($variable) EndIf If $prompt = 6 Then _Exit() EndIf ;~ Func _Exit() ;~ Exit ;~ EndFunc ;==>_Exit EndFunc ;==>Debug Edited June 16, 2020 by gcue
DatMCEyeBall Posted August 26, 2013 Posted August 26, 2013 For variables I've always used: Local $aArray[2] = ["one", "two"] $MyVar = 500 _DebugVar("$aArray") _DebugVar("$MyVar") _DebugVar("$DoesNotExist") Func _DebugVar($sVarString) If StringLeft($sVarString, 1) = "$" Then $sNewVarString = $sVarString Else $sNewVarString = "$" & $sVarString EndIf Execute($sVarString) If @error Then ConsoleWrite("! Invalid Var """ & $sVarString & """" & @CRLF) Return 0 EndIf If Execute("IsArray(" & $sNewVarString & ")") Then For $x = 0 To Execute("UBound(" & $sNewVarString & ")") - 1 ConsoleWrite($sNewVarString & "[" & $x & "] (" & VarGetType(Execute($sNewVarString & "[" & $x & "]")) & ") = " & Execute($sNewVarString & "[" & $x & "]") & @CRLF) Next Else ConsoleWrite($sNewVarString & " (" & VarGetType(Execute($sNewVarString)) & ")" & " = " & Execute($sNewVarString) & @CRLF) EndIf Return 1 EndFunc "Just be fred, all we gotta do, just be fred." -Vocaliod "That is a Hadouken. A KAMEHAMEHA would have taken him 13 days and 54 episodes to form." - Roden Hoxha @tabhooked Clock made of cursors ♣ Desktop Widgets ♣ Water Simulation
gcue Posted March 29, 2020 Author Posted March 29, 2020 (edited) expandcollapse popupFunc Debug($variable1 = "", $variable2 = "", $variable3 = "") ;~ #include <array.au3> ;~ $msg_prompt= 262148 If IsArray($variable1) Then _ArrayDisplay($variable1, "Debug") Else $variable = "" $variable = "Var1: " & $variable1 If $variable = "" Then $variable = $variable2 Else $variable &= @CRLF & "Var2: " & $variable2 EndIf If $variable = "" Then $variable = $variable3 Else $variable &= @CRLF & "Var3: " & $variable3 EndIf $prompt = MsgBox($msg_prompt, "Debug", $variable & @CRLF & @CRLF & "Exit?") If $variable <> "" Then $variable = StringRegExpReplace($variable, "Var[\d]: ", "") ClipPut($variable) EndIf If $prompt = 6 Then _Exit() EndIf ;~ Func _Exit() ;~ Exit ;~ EndFunc ;==>_Exit EndFunc ;==>Debug Edited June 16, 2020 by gcue updated script
gcue Posted November 17, 2023 Author Posted November 17, 2023 (edited) improved version - will display script line number (only when not compiled), variable summary - array/string - then display values expandcollapse popup$array = Get_Array() $string = "sjty" ;~ ConsoleWrite("ex: " & 1 & @CRLF) ;~ Debug($array) ;~ ConsoleWrite("ex: " & 2 & @CRLF) ;~ Debug($string) ;~ ConsoleWrite("ex: " & 3 & @CRLF) ;~ Debug($string, $array, $string) ;~ ConsoleWrite("ex: " & 4 & @CRLF) ;~ Debug($array, $string) ;~ ConsoleWrite("ex: " & 5 & @CRLF) ;~ Debug($string, $array) ;~ ConsoleWrite("ex: " & 6 & @CRLF) ;~ Debug($array, $string, $string) ;~ ConsoleWrite("ex: " & 7 & @CRLF) ;~ Debug($array, $string, $array) ;~ ConsoleWrite("ex: " & 8 & @CRLF) ;~ Debug($string, $string, $string) ;~ ConsoleWrite("ex: " & 9 & @CRLF) ;~ Debug($array, $array, $array) ;~ ConsoleWrite("ex: " & 10 & @CRLF) ;~ Debug($string, $array, $array) Func Debug($variable1 = "", $variable2 = "", $variable3 = "", $script_line_number = @ScriptLineNumber) $variable = "" $strings = 0 $arrays = 0 If $variable1 = "" And $variable2 = "" And $variable3 = "" Then $prompt = MsgBox($msg_prompt, "Debug (line " & $script_line_number & ")", "Exit?") If $prompt = 6 Then _Exit() EndIf If IsArray($variable1) Then $arrays += 1 $variable &= "Var1: {ARRAY}" & @CRLF ElseIf $variable1 <> "" Then $strings += 1 $variable &= "Var1: " & $variable1 & @CRLF EndIf If IsArray($variable2) Then $arrays += 1 $variable &= "Var2: {ARRAY}" & @CRLF ElseIf $variable2 <> "" Then $strings += 1 $variable &= "Var2: " & $variable2 & @CRLF EndIf If IsArray($variable3) Then $arrays += 1 $variable &= "Var3: {ARRAY}" & @CRLF ElseIf $variable3 <> "" Then $strings += 1 $variable &= "Var3: " & $variable3 & @CRLF EndIf If $strings > 0 Then If $arrays = 0 Then $prompt = MsgBox($msg_prompt, "Debug (line " & $script_line_number & ")", $variable & @CRLF & @CRLF & "Exit?") $variable = StringRegExpReplace($variable, "Var[\d]: ", "") ClipPut($variable) If $prompt = 6 Then _Exit() Else MsgBox($msg_normal, "Debug (line " & $script_line_number & ")", $variable) $variable = StringRegExpReplace($variable, "Var[\d]: ", "") ClipPut($variable) EndIf EndIf If IsArray($variable1) Then _ArrayDisplay($variable1, "1 (line " & $script_line_number & ")") If IsArray($variable2) Then _ArrayDisplay($variable2, "2 (line " & $script_line_number & ")") If IsArray($variable3) Then _ArrayDisplay($variable3, "3 (line " & $script_line_number & ")") EndFunc ;==>Debug Func Get_Array() Local $array[3] $array[0] = "faree" $array[1] = "34teg4" $array[2] = "a4t94m" Return $array EndFunc ;==>get_array Edited January 1, 2024 by gcue
gcue Posted January 1, 2024 Author Posted January 1, 2024 debug(0) was not displaying anything expandcollapse popupFunc Debug($variable1 = "", $variable2 = "", $variable3 = "", $script_line_number = @ScriptLineNumber) $variable = "" $strings = 0 $arrays = 0 If IsNumber($variable1) And $variable1 = 0 Then $variable1 = "0" If IsNumber($variable2) And $variable2 = 0 Then $variable2 = "0" If IsNumber($variable3) And $variable3 = 0 Then $variable3 = "0" If $variable1 = "" And $variable2 = "" And $variable3 = "" Then $prompt = MsgBox($msg_prompt, "Debug (line " & $script_line_number & ")", "Exit?") If $prompt = 6 Then _Exit() EndIf If IsArray($variable1) Then $arrays += 1 $variable &= "Var1: {ARRAY}" & @CRLF ElseIf $variable1 <> "" Then $strings += 1 $variable &= "Var1: " & $variable1 & @CRLF EndIf If IsArray($variable2) Then $arrays += 1 $variable &= "Var2: {ARRAY}" & @CRLF ElseIf $variable2 <> "" Then $strings += 1 $variable &= "Var2: " & $variable2 & @CRLF EndIf If IsArray($variable3) Then $arrays += 1 $variable &= "Var3: {ARRAY}" & @CRLF ElseIf $variable3 <> "" Then $strings += 1 $variable &= "Var3: " & $variable3 & @CRLF EndIf If $strings > 0 Then If $arrays = 0 Then $prompt = MsgBox($msg_prompt, "Debug (line " & $script_line_number & ")", $variable & @CRLF & @CRLF & "Exit?") $variable = StringRegExpReplace($variable, "Var[\d]: ", "") ClipPut($variable) If $prompt = 6 Then _Exit() Else MsgBox($msg_normal, "Debug (line " & $script_line_number & ")", $variable) $variable = StringRegExpReplace($variable, "Var[\d]: ", "") ClipPut($variable) EndIf EndIf If IsArray($variable1) Then _ArrayDisplay($variable1, "1 (line " & $script_line_number & ")") If IsArray($variable2) Then _ArrayDisplay($variable2, "2 (line " & $script_line_number & ")") If IsArray($variable3) Then _ArrayDisplay($variable3, "3 (line " & $script_line_number & ")") EndFunc ;==>Debug
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