[Suggestion] group repeated lines "Lines most recently executed"; built-in variables used "Variables and their contents"

Discuss the future of the AutoHotkey language
somethingfly
Posts: 38
Joined: 23 Mar 2015, 17:23

[Suggestion] group repeated lines "Lines most recently executed"; built-in variables used "Variables and their contents"

08 Nov 2017, 13:30

So, I'd make two small changes to the logging under "View" in "Lines most recently executed" and "Variables and their contents." There could be very good reasons against this, but thought I'd throw it out there.

1.

In "Lines most recently executed," if I'm in a loop, I might look and see nothing but:

Code: Select all

---- scriptlocation\script.ahk
073: if (match!="")  
074: Result .= match . ","  
077: }
071: foundpos:=regexmatch(haystack,"(?:[a-z0-9!#$%&'*+/=?^_{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_{|}~-]+)*|""(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*"")@(?:(
072: StringTrimLeft,Haystack,Haystack,%nextpos%
073: if (match!="")  
074: Result .= match . ","  
077: }
...
071: foundpos:=regexmatch(haystack,"(?:[a-z0-9!#$%&'*+/=?^_{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_{|}~-]+)*|""(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*"")@(?:(
072: StringTrimLeft,Haystack,Haystack,%nextpos%
073: if (match!="")  
074: Result .= match . ","  
077: }
071: foundpos:=regexmatch(haystack,"(?:[a-z0-9!#$%&'*+/=?^_{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_{|}~-]+)*|""(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*"")@(?:(
072: StringTrimLeft,Haystack,Haystack,%nextpos% (0.95)
Where the "..." is about a 70 repeats of:

Code: Select all

 071: foundpos:=regexmatch(haystack,"(?:[a-z0-9!#$%&'*+/=?^_{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_{|}~-]+)*|""(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*"")@(?:(
072: StringTrimLeft,Haystack,Haystack,%nextpos%
073: if (match!="")  
074: Result .= match . ","  
077: }
That's very little useful information. What happened before it? How many times has it been looping? How about instead:

Code: Select all

---- scriptlocation\script.ahk
001: some code
002: some more code
004: you get the idea
020: all the stuff that came before the loop
069: Loop
---- Repeated: 743
071: foundpos:=regexmatch(haystack,"(?:[a-z0-9!#$%&'*+/=?^_{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_{|}~-]+)*|""(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*"")@(?:(
072: StringTrimLeft,Haystack,Haystack,%nextpos%
073: if (match!="")  
074: Result .= match . ","  
077: }
----
071: foundpos:=regexmatch(haystack,"(?:[a-z0-9!#$%&'*+/=?^_{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_{|}~-]+)*|""(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*"")@(?:(
072: StringTrimLeft,Haystack,Haystack,%nextpos% (0.95)
This could either be a change to "Lines most recently executed Ctrl+L" or it could be a new view called "Dense lines most recently executed Ctrl+D" (I would say "Condensed", but following the format of the other views, the hotkey would be Ctrl+C, which would be less ideal for obvious reasons).

2.

In "Variables and the Contents" it shows much useful information. This and the other view are the only two I typically use. But I often find myself using the built-in variables (as do most people), such as "a_index" in my script (or a_screenwidth, or a_cursor, etc.). Now, there are tons of bulit-in variables, so it would be foolish to display them all. However, if a built-in variable ever gets called in a script, then I want to see its current value (even if it's not in the last line executed). If for example a script has

Code: Select all

Loop, 3
{
     if (a_index = 2)
        msgbox, I'm using a built-in variable in my script
}
return
Then (I think) a_index should be show be shown with whatever value it might have when I go to Variables and the Contents (note, I have no idea what the VarSetCapacity is of a_index, I'm just making up the stuff in the brackets). For example, if last line executed was the "msgbox" then it would show:

Code: Select all

Local Variables for Function()
--------------------------------------------------
variable1[0 of 0]:

Global Variables (alphabetical)
--------------------------------------------------
variable2[1 of 3]: 0

Used Bulit-In Variables (alphabetical)
--------------------------------------------------
a_index[1 of 3]: 2
And if the last line executed was the "return" it would show:

Code: Select all

Local Variables for Function()
--------------------------------------------------
variable1[0 of 0]:

Global Variables (alphabetical)
--------------------------------------------------
variable2[1 of 3]: 0

Used Bulit-In Variables (alphabetical)
--------------------------------------------------
a_index[0 of 3]:
Anyway, these are my humble suggestions. Thanks for reading.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: [Suggestion] group repeated lines "Lines most recently executed"; built-in variables used "Variables and their conte

08 Nov 2017, 17:27

- I thought I'd mention some points just in case they were useful to you.
- I often use a ToolTip or MsgBox to report information when experimenting. For long-running scripts I use something like _vIndex := A_Index, to store information at the top of the variables list, to monitor the progress of scripts, although not to debug them.
- For loops you could do ListLines, Off and ListLines, On before and after. I actually never use the line history, if I'm having problems trying to diagnose a script, I pop in MsgBoxes or assign variables at different points.
- I'm curious as to why 'A_' variables weren't put in the variable list. But that doesn't mean I'm asking the dev(s) to add it. Logically, I suppose if you did that, then every 'A_' variable should be there, there's no logical criteria for excluding any.
- For me re. the line history, the question is: what's the maximum size we can have for the line history, which in theory, you could then parse.
- To me, these are good ideas. It probably won't surprise you to know that people are very sparing about adding things to AHK, even if they think they're good ideas.

I've written a wish list here, if it's of any interest.
Wish List 2.0 - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 13&t=36789
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
somethingfly
Posts: 38
Joined: 23 Mar 2015, 17:23

Re: [Suggestion] group repeated lines "Lines most recently executed"; built-in variables used "Variables and their conte

08 Nov 2017, 18:18

"jeeswg",
- thanks for the points.
-I do use ToolTip and MsgBox. I have no recollection of how many times I've written "msgbox, check" into a script. But, that's only useful after I find a script has problems. The log is usually my first goto, especially if I don't want to have to restart a script. As for _vindex, again, that would only be helpful when i expect I'm going to need to monitor it, but I'll keep it in mind.
- listlines is interesting, but again, I don't want to add to my code when, again, we always hope it works right the first time and wouldn't need it. But I wasn't aware of it, so that's good to know.
- "there's no logical criteria for excluding any." Well, the logic in my suggest is: "if a built-in variable ever gets called in a script". Because as I also said "Now, there are tons of bulit-in variables, so it would be foolish to display them all." So, the logic is simple, if it is in the script, then consider it "declared" so-to-speak and worth putting in the variable list. If it is not used in the script, do not display it.
- yeah, would be nice to change the length of the line history. But that suggests either global options (something autohotkey doesn't seem to do) or setting it in the scirpt. Setting in the script, kind of like the listlines, would be fine, but again, I don't want to clutter my script so I'd probably not even use it because I'd probably do the Tooltip and msgboxes and whatnot. Still, would be a nice to have function maybe.
- thanks for agreeing on the ideas. I understand being sparring about adding to AHK, that's why I suggested such small changes.

Thanks again.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: [Suggestion] group repeated lines "Lines most recently executed"; built-in variables used "Variables and their conte

08 Nov 2017, 18:31

Actually yes, there was a logical subset as you pointed out. I guess I was thinking of variables that may be set by commands but that don't explicitly appear in the script e.g. (Set/A_)TitleMatchMode (A_)DetectHiddenWindows.

Yes, it reminds me of when I first used AutoHotkey a long time ago, and that potentially how I do things now has been shaped by what is/isn't available.

[EDIT:] Like with anything, you get little surprises about what is/isn't available. I'd say that AutoHotkey the language is pretty complete, but that the diagnostics has stayed pretty static, with the exception of ScriptInfo and DebugVars by lexikos, which I mention lower down, which pretty much fill the gaps. So if I can get what I want reasonably easily, I'm not always desperate to want AHK fixed.

There is this which may get some of the 'A_' variables for a script.
DebugVars - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=24984

One idea, a bit of a stretch is to repeatedly grab the ListLines text, together with SetTimer.
ScriptInfo(): Get ListLines/ListVars/ListHotkeys/KeyHistory text - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=9656

For common script lines like MsgBox, check, you could create a hotstring and/or a function.

I also use a hotkey to refresh the script, which checks the title of the active Notepad window, to know which script to reload. So I'm very used to restarting my script multiple times.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “AutoHotkey Development”

Who is online

Users browsing this forum: No registered users and 21 guests