Jump to content

Another debugger for AutoIt


Heron
 Share

Recommended Posts

DEMO VIDEO DBUG demo

Update 4, files are changed! 28-jan-2010

- new buttons for debugging and managing the expressions list (add, delete, save, restore)

- button images

- pause button

- mouse over variable names in the source code displays the current variable value as tooltip!

Posted Image

Features

- Debug the complete script or just parts of it

- Display run status (linenumber of currently executed function)

- GUI default always-on-top in the upper right corner for comfortable debugging

- WM_NOTIFY and WM_COMMAND hook to prevent interference with possible message handlers

- Display scope, type and value of variables, expressions, macro's and constants (global AND function local)

- Execute commands in an immediate window. Can be expressions, functions and assignments

- Detailed display of array, struct and object variables

- Dynamic display of variable value in the source code (under cursor)

Useage

1) #include <dbug.au3> as first line of the script to debug (after placing dbug.au3 in the include folder of course)

2) copy the images in a folder IMAGES on the same level as the Include folder

3) run the script!

That's all. Take special care when debugging message handlers, when they don't return fast enough, strange things may happen. To prevent this, you may add a line ;STOP DBUG before the part you want to exclude from debugging until the line ;START DBUG (or the end of the script).

Update 3, files are changed!

Extended to debug complete scripts, not just lines.

Update2

Although the GUI looks the same, the script is completely rewritten. Changes:

- More reliable: debugger doesn't fail on constants and not declared variables.

- No limitation to the count of variables that are read.

- Determination of variable scope is correct.

- Indication of breakpoint line when used with SciTE.

- Re-entry of the debugger is prevented and indicated.

Update

Damn, I found a serious flaw in the script. The basic idea is to Execute() a function with the local variables as arguments. To be changable at debug time they are passed ByRef. This works wonderfull for variables but when constants are passed then the Execute() fails silently. I don't see how I can prevent this, anybody any idea?

Original post

Hi Gents,

when playing with AutoIt I felt the need of an easy way to debug a bit more sophisticated then endless adding msgbox and consolewrites to my scripts. After looking around I start thinking of a way to make local variables visible outside there scope and came up with Dbug.au3. It's far from perfect but I wanted to share with you. Hope to hear your comments and maybe you find it usefull.

By now the features are:

- display scope, type and value of variables, expressions, macro's and constants (global AND function local)

- execute commands in an immediate window. Can be expressions, functions and assignments

- detailed display of array, struct and object variables

- set a breakpoint expression

Limitations are there also:

- max 20 variables to display

- scope display is not as reliable as it should be

- when there is a not declared variable in the debugged function, debugging fails without an errormessage (Opt('MustDeclareVars', 1) helps)

- multiple debug windows not allowed (but who does need them anyway?)

- and without doubt more not yet discovered bugs!

Examples:

display: binary($var), @scriptdir, $var_a & $var_b, $arr[1][2], timerinit(), etc

commands: $a = $b, ($c >= $d), $struc, $arr[3][4] = 'testDBUG', StringRegExp('TestDBUG', 'D(.*)', 2), etc, etc

Usage:

- Include the debug script dbug.au3 in the script you want to debug.

- Write Execute(_debug()) on every line you want to inspect.

- That's all!

To play right away I supplied a little test script too (TestDBUG.au3)

Files:

dbug.au3 - debug script (Update 3 downloads: 94)

IMAGES - Folder with fancy button images

TestDBUG.au3 - declaration of some variables and calls to debugger

I really like to know what you think of it and if you can use it. I spent far more time on it then planned :D So feedback is appreciated!

IMAGES.ZIP

Dbug.au3

TestDBUG.au3

Edited by Heron
Link to comment
Share on other sites

Hi,

nice idea. :D

There's a great debugger project by Stumpii, see here.

You may download the debugger from Stumpii's web site here.

Ciao,

Martini

Thanks Martini! I remember trying Stumpii's once but I like a lightweighted, all AutoIt debugger. So there's my attempt. But it seems my script doesn't handle constants, so that's a serious drawback (understatement) :D

Link to comment
Share on other sites

Thanks Martini! I remember trying Stumpii's once but I like a lightweighted, all AutoIt debugger. So there's my attempt. But it seems my script doesn't handle constants, so that's a serious drawback (understatement) :)

You might get some ideas from the debugger I wrote but don't maintain. It's pure AutoIt and sounds like it uses a similar idea to yours. I have a vague memory that it crashes in Vista in which case it might not be much help at all, but I could explain the workings of it to you. There's no reason you shouldn't be able to handle constants. My script can handle those and macros as well as any variable in a script including arrays but you have to specify an element.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

You might get some ideas from the debugger I wrote but don't maintain. It's pure AutoIt and sounds like it uses a similar idea to yours. I have a vague memory that it crashes in Vista in which case it might not be much help at all, but I could explain the workings of it to you. There's no reason you shouldn't be able to handle constants. My script can handle those and macros as well as any variable in a script including arrays but you have to specify an element.

Hi Martin,

I think your debugger is much more advanced, mine is more an advanced msgbox(). The whole idea is passing variables By Reference to the debugger function. In this way it is possible to display, but also assign variables manually which is a big plus. However, you can't pass a constant to a ByRef function parameter as you know, so this is where it fails. Is there a way to check if a variable is a constant, something like IsConst($var) that you know?

Link to comment
Share on other sites

Hi Heron,

I haven't had a chance to try your code yet but I'm sure I'll get some use out of it. I've been tinkering with something similar based on _dumpVar.au3 and AutoItInfo.au3( worth checking out ), and was in the process of upgrading it to a "visual test-case generator",.. but after finding this code I may be back to the ol' drawing board. It looks like your script allows you to test or adjust params/vars on the fly without the need to re-run, is that right? If that's the case then I'll have to get my turd back up on the hoist. ( once I've given it a good tongue-lashing ) :)

I'll try and get back to you with some feedback.

Thanks for sharin', Heron!

whoa,.. I'm a poet and didn't even know that I was one. :)

Link to comment
Share on other sites

Hi Heron,

I haven't had a chance to try your code yet but I'm sure I'll get some use out of it. I've been tinkering with something similar based on _dumpVar.au3 and AutoItInfo.au3( worth checking out ), and was in the process of upgrading it to a "visual test-case generator",.. but after finding this code I may be back to the ol' drawing board. It looks like your script allows you to test or adjust params/vars on the fly without the need to re-run, is that right? If that's the case then I'll have to get my turd back up on the hoist. ( once I've given it a good tongue-lashing ) :)

I'll try and get back to you with some feedback.

Thanks for sharin', Heron!

whoa,.. I'm a poet and didn't even know that I was one. :)

Dolemite50,

indeed the script allows for changing on the fly of global variables but also of local variables in the function! The commandline also gives a way to play and test all kind of built-in functions. For example type StringRegExp('abcde', '',2) and inspect the contents of the result array immediatly, it's fun! Also allowed are stupid things as $arr[1] = $obj or Msgbox(0,'',$var). Try it.

to get my turd back up on the hoist. ( once I've given it a good tongue-lashing )

Don't understand with my broken english, but do I want to know? :P

_dumpVar.au3 I don't know, what is it and where can I find it?

Thanks for your reply

Link to comment
Share on other sites

You might get some ideas from the debugger I wrote but don't maintain. It's pure AutoIt and sounds like it uses a similar idea to yours. I have a vague memory that it crashes in Vista in which case it might not be much help at all, but I could explain the workings of it to you. There's no reason you shouldn't be able to handle constants. My script can handle those and macros as well as any variable in a script including arrays but you have to specify an element.

Martin, your debugger looks sharp! At first-glance I see alot of features that were on my wish-list and it raises the question...what gives? Why did you abandon it? Were there any pitfalls or headaches beyond the Vista stuff or do you just prefer using something else? Sorry to pry, I'm just trying to determine if creating my own would be a waste of time.

Link to comment
Share on other sites

Don't understand with my broken english, but do I want to know? :)

Sorry about that Heron, your English was just fine so I assumed you were a fellow yank. You didn't miss anything worth repeating.

I couldn't find the VarDump script after a quick search on the board so I'll just post it. It looks like Rob Saunders was the original author. I'm *pretty sure* this isn't one that I've changed but it's possible because I've had "ol' Trusty" for a few years now I think.

:)

#include-once

#cs ====================================================================================================================
    AutoIt Version: 3.2.13.5
    Language:       English
    Description:    Functions for dumping variable information.
    Note:           We used to be able to dump detailed information for structures (DllStruct) because their data was
                    accessible via an array format, I did not realize this ability was taken out at some point and as
                    such we can no longer retrieve that information, so now we just dump the structure size from DllStructGetSize().
    Function List:
        _VarDumpByRef
        _VarDump
        _VarDumpArray (internal usage intended)
        _VarDumpStruct (internal usage intended)
#ce ====================================================================================================================

#cs --------------------------------------------------------------------------------------------------------------------
    Syntax:         _VarDumpByRef(ByRef $vVar, $vDumpType)
    Description:    This function returns information about the variable given as well as it's contents (if applicable/available).
    Parameters:     $vVar       - The variable to read.
                    $vDumpType  - How to display the variable information. See Notes for keywords.
                    $sIndent    - Internal usage, please do not fill this parameter.
    Return values:  String containing information about the variable. This is returned regardless of the $vDumpType parameter.
    Author:         Rob Saunders (rob at therks dot com)
    Remarks:        Arrays are fully explored and returned regardless of how many subscripts or dimensions there are. This means that
                    the function can take a while with a large array.
                    This function will also properly detail arrays within arrays, a feature not explicitly supported by AutoIt.
                    The variable must be passed by reference for this function. This means _VarDumpByRef('Hello') will error.
                    If you want to test an expression instead of a variable use _VarDump() ie: _VarDump(StringSplit('Expression', ''), 'mb').
    Notes:          Keywords for the $vDumpType parameter (these are all strings):
                        ConsoleWrite, Console, CW   = ConsoleWrite()
                        MsgBox, Msg, Box, MB        = MsgBox()
                        ToolTip, Tip, TT            = ToolTip()
                        Clipboard, Clip, CB         = ClipPut()
                        GUI, Window, Text           = Display in an edit control in a GUI window created on the fly
                    Any invalid keyword shows nothing.
                    
                    Certain variable types display in certain ways:
                        Strings:
                            String(Length) Value
                            ie: String(6) Foobar
                        Binary:
                            Binary(Length) Value
                            ie: Binary(8) 0x426F6F6269657321
                        Objects:
                            Object(Name)
                            ie: Object(IShellDispatch4)
                        DllStruct:
                            DllStruct(Size)
                            ie: DllStruct(140)
                        Arrays:
                            Array(
                                [i] => VarDump Value
                                [i] => VarDump Value
                                ...
                            )
                            ie:
                            Array(
                                [0][0] => Int32(176)
                                [0][1] => String(0) 
                                [1][0] => String(27) TF_FloatingLangBar_WndTitle
                                [1][1] => Ptr(0x000B0AA6)
                            )
                        Anything else:
                            VariableType(Content)
                            ie: Int32(123), Double(4.56), Ptr(0x008C03F4), etc.

    Example:
                    #include <Variable.au3>

                    $string = 'Hello world'
                    $struct = DllStructCreate('int var1;ubyte var2;uint var3;char var4[128]')
                    $handle = WinGetHandle('')
                    $object = ObjCreate("shell.application")
                    $binary = Binary('0x204060')
                    $number = Random()
                    $array = StringSplit($string, 'l')

                    Global $parentArray[7] = [ $string, $struct, $handle, $object, $binary, $number, $array ]

                    _VarDumpByRef($parentArray, 'window')                   
                    
                    Displays this:
                        Array(
                            [0] => String(11) Hello world
                            [1] => DllStruct(140)
                            [2] => Ptr(0x008C03F4)
                            [3] => Object(IShellDispatch4)
                            [4] => Binary(3) 0x204060
                            [5] => Double(0.835810673423111)
                            [6] => Array(
                                [0] => Int32(4)
                                [1] => String(2) He
                                [2] => String(0) 
                                [3] => String(5) o wor
                                [4] => String(1) d
                            )
                        )
#ce --------------------------------------------------------------------------------------------------------------------
Func _VarDumpByRef(ByRef $vVar, $vDumpType = Default, $sIndent = '')
    Local $sVarDump
    Local $sVarType = VarGetType($vVar)
    Switch $sVarType
        Case 'Array'
            $sVarDump = 'Array(' & @CRLF & _VarDumpArray($vVar, $sIndent & @TAB) & @CRLF & $sIndent & ')'
        Case 'DllStruct'
            $sVarDump = 'DllStruct(' & @CRLF & _VarDumpStruct($vVar, $sIndent & @TAB) & $sIndent & ')'
        Case 'Binary'
            $sVarDump = 'Binary(' & BinaryLen($vVar) & ') ' & $vVar
        Case 'Object'
            $sVarDump = 'Object(' & ObjName($vVar) & ')'
        Case 'String'
            $sVarDump = 'String(' & StringLen($vVar) & ') ' & $vVar
        Case Else
            $sVarDump = $sVarType & '(' & $vVar & ')'
    EndSwitch
    
    Switch $vDumpType
        Case 1, 'ConsoleWrite', 'Console', 'CW'
            ConsoleWrite($sVarDump & @CRLF)
        Case 2, 'MsgBox', 'Msg', 'Box', 'MB'
            MsgBox(0x2040, 'VarDump', $sVarDump)
        Case 3, 'ToolTip', 'Tip', 'TT'
            ToolTip($sVarDump)
        Case 4, 'Clipboard', 'Clip', 'CB'
            ClipPut($sVarDump)
        Case 5, 'GUI', 'Window', 'Text'
            Local Const $__WS_OVERLAPPEDWINDOW = 0xCF0000
            Local Const $__GUI_DOCKBORDERS = 102
            Local Const $__GUI_EVENT_CLOSE = -3
            Local $iGUIOnEventMode = Opt('GUIOnEventMode', 0)
            Local $guiVarDump = GUICreate('VarDump', 300, 200, Default, Default, $__WS_OVERLAPPEDWINDOW)
            GUICtrlCreateEdit($sVarDump, 0, 0, 300, 200)
                GUICtrlSetResizing(-1, $__GUI_DOCKBORDERS)
            GUISetState(@SW_SHOW, $guiVarDump)
            Do 
            Until GUIGetMsg() = $__GUI_EVENT_CLOSE
            GUIDelete($guiVarDump)
            Opt('GUIOnEventMode', $iGUIOnEventMode)
    EndSwitch
    Return $sVarDump
EndFunc

#cs --------------------------------------------------------------------------------------------------------------------
    Syntax:         _VarDump($vVar)
    Description:    A wrapper for _VarDumpByRef() to allow expressions as well as variables.
    Parameters:     $vVar       - The variable to dump.
                    $vDumpType  - How to dump the variable information. See remarks for available flags.
    Return values:  String containing the information about the variable.
    Author:         Rob Saunders (rob at therks dot com)
    Remarks:        Useful if you want to test an expression instead of a variable.
                    * IE: _VarDump(StringRegExp($string, $pattern), 'msg')
#ce --------------------------------------------------------------------------------------------------------------------
Func _VarDump($vVar, $vDumpType = Default)
    Return _VarDumpByRef($vVar, $vDumpType)
EndFunc

#cs --------------------------------------------------------------------------------------------------------------------
    Syntax:         _VarDumpArray(ByRef $aArray)
    Description:    This function is primarily intended to be used by _VarDumpByRef to evaluate array contents, but you can
                    use it by itself if you wish.
    Parameters:     $aArray - The array to evaluate.
    Return values:  Structured output of array contents.
                    If $aArray is not an array, returns an error string and sets @error to 1.
    Author:         Rob Saunders (rob at therks dot com)
#ce --------------------------------------------------------------------------------------------------------------------
Func _VarDumpArray(ByRef $aArray, $sIndent = '')
    If Not IsArray($aArray) Then
        ;~ This error check should only be applicable to when this function is used by itself.
        SetError(1)
        Return 'Error: Non-array variable given.'
    EndIf
    Local $sDump
    Local $sArrayIndex, $sArrayRead, $bDone
    Local $iSubscripts = UBound($aArray, 0)
    If $iSubscripts < 1 Then
        ;~ This probably won't ever happen, but who knows.
        Return $sIndent & '!! Array has 0 subscripts'
    EndIf
    Local $aUBounds[$iSubscripts]
    Local $aCounts[$iSubscripts]
    For $i = 0 To $iSubscripts - 1
        $aUBounds[$i] = UBound($aArray, $i + 1)
        $aCounts[$i] = 0
        If $aUBounds[$i] < 1 Then
            Return $sIndent & '!! Array subscript [' & $i + 1 & '] size is ' & $aUBounds[$i]
        EndIf
    Next
    While 1
        $bDone = True
        $sArrayIndex = ''
        For $i = 0 To $iSubscripts - 1
            $sArrayIndex &= '[' & $aCounts[$i] & ']'
            If $aCounts[$i] < $aUBounds[$i] - 1 Then $bDone = False
        Next
        
        $sArrayRead = Execute('$aArray' & $sArrayIndex)
        If @error Then
            ;~ I hope this will be a rare occurrence but it has happened to me before.
            $sDump &= $sIndent & $sArrayIndex & ' !! Error reading index'
            ExitLoop
        Else
            $sDump &= $sIndent & $sArrayIndex & ' => ' & _VarDumpByRef($sArrayRead, Default, $sIndent)
            If $bDone Then
                Return $sDump
            Else
                $sDump &= @CRLF
            EndIf
        EndIf
        
        For $i = $iSubscripts - 1 To 0 Step -1
            $aCounts[$i] += 1
            If $aCounts[$i] >= $aUBounds[$i] Then
                $aCounts[$i] = 0
            Else
                ExitLoop
            EndIf
        Next
    WEnd
    Return $sDump
EndFunc


#cs --------------------------------------------------------------------------------------------------------------------
    Syntax:         _VarDumpStruct(ByRef $tStruct)
    Description:    This function is primarily intended to be used by _VarDumpByRef to evaluate DllStruct contents, but
                    you can use it by itself if you wish.
    Parameters:     $tStruct    - The DllStruct to evaluate.
    Return values:  Structured output of DllStruct contents.
                    If $tStruct is not a struct, returns an error string and sets @error to 1.
    Author:         Rob Saunders (rob at therks dot com)
    Note:           In older versions of AutoIt DllStructs were also Arrays. Using this quirk I was able to enumerate
                    elements' names but at some point in AutoIt's development DllStructs were no longer accessible as
                    Arrays, so this ability stopped working.
#ce --------------------------------------------------------------------------------------------------------------------
Func _VarDumpStruct(ByRef $tStruct, $sIndent = '')
    If Not IsDllStruct($tStruct) Then Return SetError(1, 0, 'Error: Non-DllStruct variable given.')
    Local $iElement = 1, $vRead, $vTest
    ; Do the initial $sDump contents - Standard fare for any struct
    Local $sDump = _
        $sIndent & '[Size] => ' & DllStructGetSize($tStruct) & @CRLF & _
        $sIndent & '[Ptr] => ' & DllStructGetPtr($tStruct) & @CRLF
    While 1
        $vRead = DllStructGetData($tStruct, $iElement)
        If @error = 2 Then ExitLoop ; If we've overstepped $iElement we're done
        
        $vTest = VarGetType($vRead)
        If $vTest = 'String' Or $vTest = 'Binary' Then
            ; Test the vartype for String or Binary, in which case we dump now because we already have the full contents
            $sDump &= $sIndent & '[' & $iElement & '] => ' & _VarDumpByRef($vRead, Default, $sIndent) & @CRLF
        Else
            ; Here we'll test to see if the element is an array by looking for an index of 2.
            DllStructGetData($tStruct, $iElement, 2)
            If @error Then
                ; @error means no index, which means no array, which means we can just dump the stored $vRead from above
                $sDump &= $sIndent & '[' & $iElement & '] => ' & _VarDumpByRef($vRead, Default, $sIndent) & @CRLF
            Else
                ; If we get no @error then that means that index 2 was valid, so we'll just start from 1 and work our way up til we @error again
                Local $sSubDump, $iIndex = 1, $iCount = 0, $iNonEmpties = 0
                While 1
                    $vRead = DllStructGetData($tStruct, $iElement, $iIndex)
                    If @error Then ExitLoop ; And that's the limit of this array, so we're done.
                    If $vRead Then
                        $sSubDump &= @TAB & $sIndent & '[' & $iIndex & '] => ' & _VarDumpByRef($vRead, Default) & @CRLF
                        $iNonEmpties += 1
                    EndIf
                    $iIndex += 1
                WEnd
                $sDump &= _
                    $sIndent & '[' & $iElement & '] => Array(' & @CRLF & _
                    $sIndent & @TAB & '> Showing ' & $iNonEmpties & '/' & ($iIndex-1) & ' non-empty indices' & @CRLF & _
                    $sSubDump & $sIndent & ')' & @CRLF
            EndIf
        EndIf
        $iElement += 1
    WEnd
    Return $sDump
EndFunc


#cs --------------------------------------------------------------------------------------------------------------------
    This is the old _VarDumpStruct function that was able to evalute element names by accessing DllStructs as Arrays
    Can't do this anymore so this function doesn't work properly. I'm leaving it in though in case I forget how I did it.

    Syntax:         _VarDumpStruct(ByRef $tStruct)
    Description:    This function is primarily intended to be used by _VarDumpByRef to evaluate DllStruct contents, but
                    you can use it by itself if you wish.
    Parameters:     $tStruct    - The DllStruct to evaluate.
    Return values:  Structured output of DllStruct contents.
                    If $tStruct is not a struct, returns an error string and sets @error to 1.
    Author:         Rob Saunders (rob at therks dot com)

Func _VarDumpStruct(ByRef $tStruct, $sIndent = '')
    Local $sDump, $iItemCount, $iItemEnum, $vItemValue, $iSubItemEnum
    If Not IsDllStruct($tStruct) Then
        Return SetError(1, 0, 'Error: Non-DllStruct variable given.')
    ElseIf Not IsArray($tStruct) Then
        ;~ Only magic or fairy dust should get us here...
        Return SetError(99, 0, 'Error: Unable to parse DllStruct (not array).')
    ElseIf IsDllStruct($tStruct) And IsArray($tStruct) Then
        If UBound($tStruct, 0) <> 2 Or UBound($tStruct, 1) < 2 Or UBound($tStruct, 2) < 5 Then
            Return SetError(2, 0, 'Error: Invalid DllStruct-Array format.')
        EndIf
        Local $iItemCount = $tStruct[0][2]
        For $iItemEnum = 1 To $iItemCount
            If IsString($tStruct[$iItemEnum][3]) And $tStruct[$iItemEnum][3] <> '' Then ; Check if element has a name
                $sDump &= $sIndent & '[' & $tStruct[$iItemEnum][3] & '] => '
            Else
                $sDump &= $sIndent & '[' & $iItemEnum & '] => '
            EndIf
            
            Local $vItemValue = DllStructGetData($tStruct, $iItemEnum)
            Switch VarGetType($vItemValue)
                Case 'String', 'Binary'
                    ; If the type of the return is string/binary, then we can dump now
                    $sDump &= _VarDumpByRef($vItemValue, Default, $sIndent)
                Case Else
                    ; Check for a 2nd index
                    DllStructGetData($tStruct, $iItemEnum, 2)
                    If @error Then
                        ; If @error then item is not an array and we can dump now
                        $sDump &= _VarDumpByRef($vItemValue, Default, $sIndent)
                    Else
                        ; Else item IS an array and we'll loop through it.
                        Local $iCountNonEmpty = 0
                        Local $sSubItemDump = ''
                        Local $iSubItemEnum = 1
                        Local $vItemValue
                        While True
                            $vItemValue = DllStructGetData($tStruct, $iItemEnum, $iSubItemEnum)
                            If @error Then ExitLoop
                            If $vItemValue <> '' Then
                                $sSubItemDump &= @TAB & $sIndent & '[' & $iSubItemEnum & '] => ' & _VarDumpByRef($vItemValue, Default, $sIndent) & @CRLF
                                $iCountNonEmpty += 1
                            EndIf
                            $iSubItemEnum += 1
                        WEnd
                        $sDump &= 'Array(' & @CRLF & @TAB & $sIndent & '> Displaying ' & $iCountNonEmpty & '/' & ($iSubItemEnum - 1) & ' items' & @CRLF & _
                            @TAB & $sIndent & '> Skipped items are empty' & @CRLF & $sSubItemDump & $sIndent & ')'
                    EndIf
            EndSwitch
            If $iItemEnum < $iItemCount Then $sDump &= @CRLF
        Next
        Return $sDump
    EndIf
EndFunc
Link to comment
Share on other sites

@Martin: I like your debugger project but it's way to complex for me. I can't even get it to work, must be doing something wrong. It says: running script in debugger and I see the debugger GUI but nothing happens when I press Start or step or whatever. Has the testscript to be in the same directory?

Can you explain the basic idea of your debugger? How do you get the variable values read? Is the test script first rewritten with debug statements?

(I know, a fool can ask more then 100 wise men can answer...)

Link to comment
Share on other sites

@Dolemit50,

indeed, varDump looks much like the way I print variables and I can see how it works. I liked the idea of displaying an array within an array. I will use it too, be it not recommended. But the use of Execute is dirty programming anyway.

Thanks for your tip!

Link to comment
Share on other sites

@Martin: I like your debugger project but it's way to complex for me. I can't even get it to work, must be doing something wrong. It says: running script in debugger and I see the debugger GUI but nothing happens when I press Start or step or whatever. Has the testscript to be in the same directory?

Can you explain the basic idea of your debugger? How do you get the variable values read? Is the test script first rewritten with debug statements?

(I know, a fool can ask more then 100 wise men can answer...)

I haven't looked at it for a long time. I originally wrote it because I thought it would be useful to have a pure AutIt debugger. Stupmpii's looked good from what I read but his needed .Net which I didn't want, but I think his doesn't need .net any more.

I'll have a look at it and get back. What version of Windows are you using? I think the editor had problems in Vista and I couldn't fix it at the time. I can't remember why I abondoned it but probably I decided I'd rather do somethjing else.

I evaluated variables and constants using Execute.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Hi, thanks for your responses and tips. I like to know how other people have dealt with the issues I face myself. I have reworked the original script of this post and left the idea of passing the function variables by reference. Now I read the variables using a recursive Execute call. Writing variables is done in the same way. Doing so the variables are evaluated in there own scope. Now there is no limitation in the number of variables that can be read and the scope of the variables is determined accurate. Furthermore the script is more robust, it does't fail when variables are not declared or are constants. I will upload it soon.

Next problem (there is always a next problem) is interfering of the debug GUI with the application's GUI's. I consider using only Hotkeys to prevent problems. Are there any tips you can give me in this area? For example: 1) the debug script doesn't know the EventMode of the application to debug, 2) the message handler of the application steals the debugger's one, 3) control ID's of the application are shifted because of the debugger's one, etc...

Link to comment
Share on other sites

Well, you can get the old GUI mode as the return value from Opt("GuiOnEventMode", 1), so

$currentMode = Opt("GuiOnEventMode", 1)
Opt("GuiOnEventMode", $currentMode)

So you can get the old mode and reset it as well.

Good point! I saw it once in the past but forget it. I will use it in the new version!
Link to comment
Share on other sites

  • 2 weeks later...

Hi there,

again a update to the original post. Now the debugger program allows for debugging the whole script, line by line. Had not much response on the first releases but hey, I had an awful lot of fun writing it. Guess I'm the only one that writes script with bugs in it :)

Link to comment
Share on other sites

  • 3 months later...
  • 7 months later...

Heron,

I found recently your debugger and I think is a great tool!!

I hope you are still working on the project...

Just some questions:

1)

It's possible (in the next release) to delete the DBugScript file on exit?

2)

Wich is the best way to monitoring array value step by step (not using code tooltips)?

3)

Can you shortly explain the meaning of the "Save list", "Restore original list" buttons?

Thanks!!

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...