gil900

GoToNextLine() - useful function I worte for easy debuging

1 post in this topic

The rule is simple, first you need set hotkey that when you  presses it, the code will continue to the next line with GoToNextLine_HotKeySet($Key)

the next step is to put the GoToNextLine() function on  every line you want to stop the executing process.

 

 I I've included an example + function:
 

GoToNextLine_HotKeySet('z') ; You need to set hotkey. You must call this function first on order to make it work!



Local $hGUI
; Create GUI
$hGUI = GUICreate("Test", 400, 300)
GoToNextLine() ; here I use it. the next line will not execute until you presses on z key (in this case)
GUISetState(@SW_SHOW)
WinSetOnTop($hGUI,'',1)
GoToNextLine('Next line will change the color to red!') ; same story but here I added extra informition..
GUISetBkColor(16711680)
GoToNextLine('Next line will delete the GUI','The GUI was deleted "now"') ; same story but I added more info after...
GUIDelete($hGUI)

GoToNextLine('In the next line I will do something else... presses z to continue.')
For $y = 0 To @DesktopHeight Step Int(@DesktopHeight*0.125)
    GoToNextLine('Now I going to next or first $y - '&$y&', and enter into the $y loop...')
    For $x = 0 To @DesktopWidth Step Int(@DesktopHeight*0.25)
        ToolTip($x&','&$y,$x,$y)
        Sleep(500)
    Next
    GoToNextLine('$y loop ended. are you sure you want to continue to the next loop or line? presses z to continue.')
Next



Func GoToNextLine_HotKeySet($Key)
    Local Static $globals
    If Not $globals Then
        Global $g_gtn_key,$g_gtn_exitloop
    EndIf
    If $g_gtn_key Then HotKeySet('{'&$g_gtn_key&'}')
    $g_gtn_key = $Key
    HotKeySet('{'&$g_gtn_key&'}','GoToNextLine_ExitLoop')
EndFunc


Func GoToNextLine($ExInfo_BeforeNext = '',$ExInfo_AfterNext = '')
    If Not IsDeclared('g_gtn_exitloop') Then Return SetError(1) ; You need to call GoToNextLine_HotKeySet() first

    Local Static $iLineCallNumber = 1
    If $ExInfo_BeforeNext Then ConsoleWrite('Description for next Call: '&$ExInfo_BeforeNext & @CRLF)
    Do
        Sleep(100)
    Until $g_gtn_exitloop
    ConsoleWrite('GoToNextLine - Call '&$iLineCallNumber& @CRLF)
    If $ExInfo_AfterNext Then ConsoleWrite('Description for this Call: '  & $ExInfo_AfterNext& @CRLF)
    $iLineCallNumber += 1
    $g_gtn_exitloop = 0
EndFunc


Func GoToNextLine_ExitLoop()
    $g_gtn_exitloop = 1
EndFunc

 

Share this post


Link to post
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