AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Show Line Number of Last Executed Line (A_LineNumber)

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
ProsperousOne



Joined: 19 Sep 2005
Posts: 96

PostPosted: Wed Jan 30, 2008 8:34 pm    Post subject: Show Line Number of Last Executed Line (A_LineNumber) Reply with quote

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
View user's profile Send private message
Tuncay



Joined: 07 Nov 2006
Posts: 384
Location: Berlin

PostPosted: Wed Jan 30, 2008 8:46 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
bernd01



Joined: 13 Feb 2008
Posts: 6

PostPosted: Wed Feb 13, 2008 12:14 am    Post subject: Reply with quote

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
View user's profile Send private message
ProsperousOne



Joined: 19 Sep 2005
Posts: 96

PostPosted: Wed Feb 13, 2008 1:09 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group