ListLines

Enables or disables line logging or displays the script lines most recently executed.

ListLines "On|Off"

Parameters

On|Off

If blank or omitted, the history of lines most recently executed is shown. The first parameter affects only the behavior of the current thread as follows:

On or 1 (true): Includes subsequently-executed lines in the history. This is the starting default for all scripts.

Off or 0 (false): Omits subsequently-executed lines from the history.

Remarks

ListLines (with no parameter) is equivalent to selecting the "View->Lines most recently executed" menu item in the main window. It can help debug a script.

ListLines "On|Off" can be used to selectively omit some lines from the history, which can help prevent the history from filling up too quickly (such as in a loop with many fast iterations). Additionally, performance is reduced by a few percent while line logging is enabled.

Every newly launched thread (such as a hotkey, custom menu item, or timed subroutine) starts off fresh with the default setting for this function. That default may be changed by using this function in the auto-execute section (top part of the script).

Although there is no built-in variable "A_ListLines", similar functionality can be achieved by including the following in a script:

global A_ListLines  ; Declare a super-global variable which can be accessed from everywhere.

_ListLines(OnOff)  ; Save the current setting into A_ListLines.
{
    A_ListLines := OnOff = "On" ? True : OnOff = "Off" ? False : OnOff
    ListLines A_ListLines
}

; To use the above function:
_ListLines "Off" ; Turn off ListLines temporarily.
; ...
_ListLines !A_ListLines  ; Restore ListLines to its previous setting.

On a related note, the built-in variables A_LineNumber and A_LineFile contain the currently executing line number and the file name to which it belongs.

Related

KeyHistory, ListHotkeys, ListVars

Example

ListLines
ListLines "Off"
ListLines False