AutoHotkey Community

It is currently May 26th, 2012, 5:30 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 40 posts ]  Go to page Previous  1, 2, 3
Author Message
 Post subject:
PostPosted: April 18th, 2009, 12:50 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
jenn wrote:
...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.)


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 18th, 2009, 5:49 pm 
Offline
User avatar

Joined: May 5th, 2007, 7:24 pm
Posts: 1240
Location: Seville, Spain
Code:
A_ListLines := true
ListLinesOn(){
    Global
    ListLines On
    A_ListLines := true
}
ListLinesOff(){
    Global
    ListLines Off
    A_ListLines := false
}


There you go 8)

_________________
fincs
Highly recommended: AutoHotkey_L (see why) (all my code snippets require it)
Formal request to polyethene - I support the unity of the AutoHotkey community
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list]


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 18th, 2009, 7:28 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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:
Code:
A_ListLines := "On"
ListLinesOn()
{
    ListLines On
    Global A_ListLines := "On"
}
ListLinesOff()
{
    ListLines Off
    Global A_ListLines := "Off"
}


Last edited by Chris on April 18th, 2009, 7:50 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 18th, 2009, 8:22 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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:
Code:
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
}
Code:
; To use the above function:
prev_ListLines := ListLines(false)  ; Turn off ListLines temporarily.
; ...
ListLines(prev_ListLines)  ; Restore ListLines to its previous setting.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 19th, 2009, 8:59 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 3rd, 2009, 7:41 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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]


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 25th, 2009, 4:15 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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]


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 25th, 2009, 8:07 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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]


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 26th, 2009, 1:28 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
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:
Code:
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:
Code:
loop("f","g")

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

f(x) {
   Return x<3
}

g(x) {
   MsgBox %x%
}


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 26th, 2009, 3:13 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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 www.autohotkey.com/forum/viewtopic.php?t=47232, in which a lot of people expressed support for the change; and no one really said anything against it.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 40 posts ]  Go to page Previous  1, 2, 3

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group