Jump to content

Function For Code Line


Recommended Posts

I'm trying to throw together a bit of a crude debugging tool, and had a question about calling out the current line of the script. I'm pretty sure it's possible because the TrayIconDebug can output the line number it's currently processing.

I'd like to have a little function like:

; Func to output current line
Func _Line ( )
    MsgBox ( 48, "Update", "Current Line: " & @CurrentLine*, 1 )
EndFunc ; --> _Line

@CurrentLine* is what I'd like to replace with a real command or function.

Basically, I'd like to call _Line throughout the code to display for a second which line it's on... kind of like informing me of it's progress so I can narrow down where it fails.

Thanks

Link to comment
Share on other sites

It's a nice idea but, speaking under correction here, I think the tray icon debug's display of the line number is at a lower level than the code-logic:

Your UDF would always display the same number .. the line where this statement appears:

MsgBox ( 48, "Update", "Current Line: " & @CurrentLine*, 1 )

:D

Link to comment
Share on other sites

Ack! You would be correct... how's about this?

...
; Script
$VAR = @CurrentLine*
_Line ( $VAR )
; Script
...

; Func to output current line
Func _Line ( $VAR )
   MsgBox ( 48, "Update", "Current Line: " & $VAR, 1 )
EndFunc; --> _Line
Link to comment
Share on other sites

You can accomplish that already with a checkpoint UDF .. :huh2:

;code code code
  ;code code code
  ;code code code

    _CheckPoint("Here i am")

  ;code code code
  ;code code code
  ;code code code

    _CheckPoint("Now I'm here, and $sSomeValue = " & $sSomeValue)

  ;code code code
  ;code code code
  ;code code code

Func _CheckPoint($psComment)
    MsgBox(4096 + 32, @ScriptName & ":: _Checkpoint()", $psComment, 1)
EndFunc

I think (hope, pray :D ) Nutster is still working on a debugger. You might have some ideas you can add here .. :)

Edited by trids
Link to comment
Share on other sites

  • 2 weeks later...

I have submitted a bunch of things to Jon and I am waiting for the next version (3.0.103) before getting into it deeply because some of the things I wrote optimize the process at a pretty deep level, that would interfere with the way the debugger would work. That and work is just burying me in stuff to do. Guess where I am this weekend? :D

David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

Link to comment
Share on other sites

well if you really want a display, you can have autoit make a temp autoit file and run that. Ex:

$file = FileOpen("test.au3", 0); what ever your autoit file
$tempfile="my_temp_file.au3"
FileDelete($tempfile)
$_x=1
; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf
; Read in lines of text until the EOF is reached
While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
filewriteline($tempfile,'tooltip("Line '&$_x &' ",0,0)')
filewriteline($tempfile, $line)
$_x=$_x+1
Wend
FileClose($file)
Run('cmd /c start '&$tempfile)

Ok, I am just having fun, and it wouldn't work if you use tooltip in your script, but this will make a quick debug while running script. :D

AutoIt3, the MACGYVER Pocket Knife for computers.

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...