Sign in to follow this  
Followers 0
pjw73nh

Best method to pause a script for debugging

6 posts in this topic

If you can't tell by my recent posts, I am attempting to come into the 90's with scripting and moving away from DOS batch files. So this is very new to me. Thank you for your patience.

In batch files it was easy to put a PAUSE command in various places to have the script stop so you could debug it., and it would then say "Press any key to contiue" What is the best means of doing this? MsgBox perhaps?

Thanks

Share this post


Link to post
Share on other sites



not sure what you want but... this isnt the 90's...


Share this post


Link to post
Share on other sites

Most of use MsgBox to debug pjw73nh, and If I'm not mistaken, there's even in an option for it in SciTe now.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

not sure what you want but... this isnt the 90's...

My (apparently poor) attempt at humor.

I guess if you were scripting in the 80's, you would understand my reference to the DOS batch command PAUSE. Without understanding this reference, I would've thought the title of the post was sufficiently descriptive.

Allow me to rephrase my request. What is the best method of indefinetly pausing the execution of a script at a particular point, so as to allow:

A. Examination of the script that has processed up to that point.

B. Operator input to continue execution of the script until the next "pause point".

Tnx

Paul...

Share this post


Link to post
Share on other sites

...into the 90's...

I get it.

The best method is to start with the SciTE4AutoIt3 Editor

http://www.autoitscript.com/autoit3/scite/

Install SciTE

Make a new "au3" file.

(Perhaps via a right mouse click on your desktop, new, AutoIt v3 Script.)

Right mouse click on that new script and select edit.

[some people just start SciTE and then are lost...

...hence the verbose instructions above.]

Write a few lines of code and select "Tools" from the menu bar at the top.

There are many debug tools there.

At least run the SyntaxCheck.

[and if your are going to post code to the forum, run "Tidy AutoIt Source" first]

Now, for your code:

Yes, a well placed msgbox is a good debug tool, but so is putting this line at the top of your scripts:

Opt("TrayIconDebug", 0) ;0=no info, 1=debug line info

While your script is running - mouse over the AutoIt icon in the system tray (down by the clock) and it might tell you the line of code that AutoIt is running. This really helps if the script seems to just stop. It might be waiting for a window title that you miss-typed into your script.

And then there is the tooltip and/or splashscreen,,, the list goes on. Different methods are "best" for different types of code. Maybe a tooltip for debugging nested loops.

"indefinetly pausing" = MsgBox without a timeout...

hope this helps


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

This is a code that LXP helped me do months ago

It has a function called Debug, everytime I need to know what is going on I called Debug("information") the information is set to debug and displayed in a msgbox and the script is paused.

#include <file.au3>
processFolder(@scriptDir)

func processFolder($path)

    local $fileHandle, $file, $dirHandle, $dir

    local const $FILESPEC = "*.raw"
 debug("Starting with " & $path)

 debug("Going to search for " & $path & "\" & $FILESPEC)
    $fileHandle = fileFindFirstFile($path & "\" & $FILESPEC)
    if ($fileHandle <> -1) then
        while (1)
            $file = fileFindNextFile($fileHandle)
            if (@error = 1) then exitLoop
            if ($file = "." or $file = "..") then continueLoop
            $file = $path & "\" & $file
            if (isFolder($file)) then continueLoop
            debug("Found file " & $file)
        ; here's the place to do any per-file manipulating
        ; $file contains the full path to the file
         
         RunWait(@COMSPEC & " /c " & @scriptDir & "\Raw2bmp.exe " & $File )
         
         debug ($Path)
         
        wEnd
        fileClose($fileHandle)
       
        $NewPath = StringReplace ( $Path, @Scriptdir & "\" , "" , 0, 0 )
        $NewDir = (  @scriptdir & "\BMP\" & $NewPath )
        DirCreate ($NewDir)
        
        FileMove ( $NewPath & "\*.BMP",   $NewDir , 1 )
        debug ($NewPath & "\*.BMP")
        
        
    ; here's the spot to do processing on any folder that contained RAWs
    ; (such as making BMP subfolders and moving files)
    endIf

debug("Going to search for subfolders")
    $dirHandle = fileFindFirstFile($path & "\*.*")
    if ($dirHandle <> -1) then
        while (1)
            $dir = fileFindNextFile($dirHandle)
            if (@error = 1) then exitLoop
            if ($dir = "." or $dir = "..") then continueLoop
            $dir = $path & "\" & $dir
            if (not(isFolder($dir))) then continueLoop
     debug("Found subfolder " & $dir)
            processFolder($dir)
        wEnd
        fileClose($dirHandle)
    endIf

endFunc

func isFolder($path)
    if stringInStr(fileGetAttrib($path), "D") then return 1
    return 0
endFunc

func debug($text)
    msgBox(0x40, "processFolder()", $text)
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
Sign in to follow this  
Followers 0