Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

v1.0.48 released: Runs up to 3x as fast. Adds while-loop.


  • Please log in to reply
39 replies to this topic
Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004

...how about a "A_ListLines" variable?
I have started using ListLines On/Off in functions where I either want to see or not see the function lines. The obvious problem is that when exiting a function that uses this, there is no current way to know what the ListLines On/Off state was when entering the function.

I had considered adding A_ListLines; but since On/Off is a debugging feature and probably won't be commonly used, it seemed like it would add more clutter to the documentation than it was worth. (The list of built-in variables is already distractingly and dauntingly long.)

fincs
  • Moderators
  • 1662 posts
  • Last active:
  • Joined: 05 May 2007
A_ListLines := true
ListLinesOn(){
    Global
    ListLines On
    A_ListLines := true
}
ListLinesOff(){
    Global
    ListLines Off
    A_ListLines := false
}

There you go 8)

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Thanks; I've added it to the documentation. I hope that will be enough for anyone who needs A_ListLines.

I changed it a little to be more consistent with some of the other A_xxx variables. The following would be included near the top of a script:
A_ListLines := "On"
ListLinesOn()
{
    ListLines On
    Global A_ListLines := "On"
}
ListLinesOff()
{
    ListLines Off
    Global A_ListLines := "Off"
}


Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Oops, I just realized it's not quite the same as a built-in variable because every function that needs to look at A_ListLines would first have to declare it as global. Maybe this is a little better:
ListLines(PassTrueToTurnOnOrFalseToTurnOff)  ; Returns the previous setting of ListLines (prior to this call).

{

	static sListLines := true  ; The starting default for all scripts is "ListLines On".

	ListLines % PassTrueToTurnOnOrFalseToTurnOff ? "On" : "Off"  ; Execute ListLines unconditionally to omit the lines executed below from the log.

	ListLines_prev := sListLines

	sListLines := PassTrueToTurnOnOrFalseToTurnOff

	return ListLines_prev

}
; To use the above function:

prev_ListLines := ListLines(false)  ; Turn off ListLines temporarily.

; ...

ListLines(prev_ListLines)  ; Restore ListLines to its previous setting.


Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Here are the changes for v1.0.48.02:

Changed and fixed Gosub and GroupActivate so that when a function calls an external/public subroutine, that subroutine will treat all dynamic variables as globals, and will have outside-of-function GUI behavior. [thanks kenomby & Lexikos]

Improved performance of True/False/A_EventInfo in expressions by treating them as integers vs. strings.

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Here are the changes for v1.0.48.03:

Fixed "ListLines On" not to erase the most recent log entry in the line history. [thanks Lexikos]

Fixed ListView to respond properly to mouse dragging when timers are running. [thanks Solar]

Fixed key-up hotkeys so that if one is created while its key is being held down, the release of the key doesn't trigger the wrong hotkey. [thanks Peter & engunneer]

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Here are the changes for v1.0.48.04 (this is mostly a bug-fix release, and most of the fixes are minor or rare except the first one below):

Fixed StringSplit to work properly inside functions of compiled scripts (broken by 1.0.35.01). [thanks engunneer & Lexikos]

Fixed SendPlay not to wait for the release of the Windows key prior to sending an "L" keystroke (broken by 1.0.48.01). [thanks Lexikos]

Fixed A_EndChar to be valid when the B0 option is present, and to be empty when there is no ending character (broken by 1.0.44.09). [thanks Al2000]

Fixed FormatTime to yield a valid time of day even when the specified month is out-of-range (broken by 1.0.48.00). [thanks silveredge78]

Fixed FileCreateDir to support a leading backslash even when it is the only backslash; e.g. \dir. [thanks jaco0646]

Fixed GuiControl/GuiControlGet/Gui/SendMessage to work reliably even when they trigger a callback or OnMessage function. [thanks Lexikos]

Fixed RegExMatch() not to produce too few replacements when an empty-string match is followed by a non-empty-string match.

Changed "While()" to be recognized as a loop rather than a function. [thanks Crash&Burn]

Improved UrlDownloadToFile to support FTP and Gopher. [thanks Lexikos]

Improved the stdout/asterisk mode of FileAppend to write immediately rather than lazily to standard output. [thanks Lexikos]

Added full support for "if % expression". [thanks kenomby]

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
v1.0.48.05 fixes a crash of SendMessage and PostMessage when wParam or lParam is omitted (broken by 1.0.48.04). [thanks Lexikos]

Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
Well, scripts get broken with the new prohibition of “while” as function name. I am not so sure that while(condition) is important to be recognized as loop. One of my broken scripts is below, but a there are more examples:
while("f","g")

while(cond,do) {
   Loop
      if %cond%(A_Index)
           %do%(A_Index)
      else Return
}

f(x) {
   Return x<3
}

g(x) {
   MsgBox %x%
}
It is also inconsistent, because replacing “while” with “loop” still works as function. The user would need a list of prohibited names, which cannot be used as function names, and maybe warnings. The following still works:
loop("f","g")

loop(cond,do) {
   while %cond%(A_Index)
      %do%(A_Index)
}

f(x) {
   Return x<3
}

g(x) {
   MsgBox %x%
}


Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Sorry for the annoyance caused by this.

It was changed because I and those discussing it at the topic below thought that it would be very rarely used as a function (but apparently it's not so rare).

More imporantly, some people who are used to other programming languages have a deeply-ingrained habit to write if() and while() [without spaces]. Since if() was already supported as "not-a-function", it seemed reasonable and consistent to do the same for while().

The original topic is <!-- w -->www.autohotkey.com/forum/viewtopic.php?t=47232<!-- w -->, in which a lot of people expressed support for the change; and no one really said anything against it.