| View previous topic :: View next topic |
| Author |
Message |
ProsperousOne
Joined: 19 Sep 2005 Posts: 96
|
Posted: Wed Jan 30, 2008 8:34 pm Post subject: Show Line Number of Last Executed Line (A_LineNumber) |
|
|
This is so simple that it's hardly worth posting, but for Noobs (like me lol) this is just a reminder/note that A_LineNumber is the internal variable showing the last line number of executed code.
It may help a lot with debugging, or where you have many error messages, and want to reference the line number where the message occured:
In my code, I have several error messages, and use the line number as an error code:
| Code: |
Msgbox, Error Code %A_LineNumber%
|
|
|
| Back to top |
|
 |
Tuncay
Joined: 07 Nov 2006 Posts: 384 Location: Berlin
|
Posted: Wed Jan 30, 2008 8:46 pm Post subject: |
|
|
On a related note to A_LineNumber, you should look at A_LineFile, which is
| AutoHotkey Documentation wrote: | | The full path and name of the file to which A_LineNumber belongs, which will be the same as A_ScriptFullPath unless the line belongs to one of a non-compiled script's #Include files. |
and the commands ListLines and ListVars. |
|
| Back to top |
|
 |
bernd01
Joined: 13 Feb 2008 Posts: 6
|
Posted: Wed Feb 13, 2008 12:14 am Post subject: |
|
|
Hi!
I have a similar problem. I have a script which runs for about 30min and then crashes suddenly. Of course I have use the "Line most recently executed" but then I have to refresh every 5 sec and when the script crashes this functions of course is not available anymore, as the script has crashed.
Therefore it would be useful, to write this lines to a log file. Then I could look at the logfile and see at what line the script crashed.
Same would be useful for Show vars...
Is there a way to do that? ListLines won't help, as it also just shows the lines...
Best regards,
Bernd |
|
| Back to top |
|
 |
ProsperousOne
Joined: 19 Sep 2005 Posts: 96
|
Posted: Wed Feb 13, 2008 1:09 am Post subject: |
|
|
You could write a script that keeps writing A_LineNumber and A_LineFile to a .txt file. Then when it crashes, you should have the last several lines prior to the crash. If the file is too large, you can write it such that it only save the last 5, 10 or 100 lines etc.
Best of Luck |
|
| Back to top |
|
 |
|