Jump to content

View current line of code that a compiled script is running


Recommended Posts

Hey there.

I am trying to trouble shoot a script after it is compiled but I need a way to see which line of code it is sticking on. I thought there was some code that could be put into a script used to show the current line of code that is executing. Like having a function to display the code as a tooltip or being able to throw it out to a log file.

A log file would probably be best as I am using it as a package for installs over our network and I don't necessarily want tooltips showing up while people are working. The compiled script works on my machine but I have seen it hang from our administrative software onto other PCs.

Any ideas?

Thanks

Be open minded but not gullible.A hammer sees everything as a nail ... so don't be A tool ... be many tools.

Link to comment
Share on other sites

Did a search in the Helpfile and found this option.

Opt("TrayIconDebug",1) ; If enabled shows the current script line in the tray icon tip to help debugging.

Might help you out a bit.

> there are 10 types of people in the world, those who understand binary and those who don't.

Link to comment
Share on other sites

Did a search in the Helpfile and found this option.

Opt("TrayIconDebug",1) ; If enabled shows the current script line in the tray icon tip to help debugging.

Might help you out a bit.

This will give you the code, but the line number will always be zero on a compiled script.

Worth a try, but multiple loops, the results are often "Sleep()"

Or, just an idea, u could read the whole script to an array and reffer to it with @ScriptLineNumber...

Can you provide an example as to how to incorporate that into a compiled script?

@LostUser:

The scripts in the FAQ page seem to be broken (possibly by the forum upgrade?), but here's a cache:

Q1. How can I debug my script?

A1. This one has myriad answers, but the most effective is to begin by using the SciTE4AutoIt3 Editor to create or edit scripts. This program is useful in debugging for the following reasons:

  • Syntax highlighting allows for immediate viewing of any mistakes from unended script tags or quotes. This allows the scripter to visibly see the difference between the following incorrect code

ControlSend("title", "text, controlID, "string"

and the corrected version

ControlSend("title", "text", controlID, "string")
  • Global Syntax check built directly into the tools menu allows you to check an entire script for problems all at once.
  • Built-in code tidying program that correctly indents utidy code and repairs messy scripts to allow them to be more readable. It also corrects problems with incorrectly capitalised function names and variables.
  • Per-line trace insertion allows you to log every line of code executed to debug errors.
  • Debug MsgBoxes or ConsoleWrites are able to be added anywhere in the script directly from SciTE. ConsoleWrite lines are less intrusive and prevent the added annoyance to the user of MsgBoxes.
A2. You can also debug a script on any computer by adding the following code to your script:

Func dbg($msg)
    DllCall("kernel32.dll", "none", "[b]OutputDebugString[/b]", "str", $msg)
EndFunc

Then, when you need to add a debug line, call it as necessary. Example:

dbg("The value of Variable 1 at this time is " & $var1)

This debugging is completely transparent to the user, and is only viewable with a program such as DebugView from SysInternals. This method of debugging has the added advantage of being available to the developer in situations where is not acceptable or feasable to install SciTE on a client's unit.

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Link to comment
Share on other sites

This will give you the code, but the line number will always be zero on a compiled script.

Worth a try, but multiple loops, the results are often "Sleep()"

Of course, my bad. One way could be to debug before compilation.

> there are 10 types of people in the world, those who understand binary and those who don't.

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