v2.0-a079-be5df98
The Big Changes
Removed legacy command syntax and %expression% substitution in strings.
That is, a "command" is now just a function or method call which sits at the start of the line, lacks parentheses and discards its return value. Aside from parentheses, commands and functions now share the same syntax. In general, functions with a single return value do not use an output variable, so usually require parentheses to be useful. See v2-changes for details.
Related changes:
- Added goto(expr) and gosub(expr) statements (not functions), since goto and gosub without parentheses do not support variables.
- Removed load-time validation code for command parameters, which no longer applied due to expressions.
- Removed LoopFiles/LoopParse/LoopRead/LoopReg (now require a space).
- Removed MsgBox's redundant OutputVar.
- Removed Deref().
- Changed `, to have no special meaning (previously it acted as though enclosed in parentheses; i.e. did not delimit command parameters). This ensures `, has the same effect regardless of whether parentheses are used.
- Removed the , and % continuation section options and the escaping of , by default, since there's no longer any reason to escape it.
- Added InputEnd(), since Input no longer has an OutputVar to omit. InputEnd sets ErrorLevel to "End".
- Added RandomSeed(), since Random no longer has an OutputVar to omit.
Implemented the new GUI API.
https://autohotkey.com/boards/viewtopic.php?f=37&t=2998
Other Syntax Changes
Changed /* to allow */ at the end of the line. See v2-changes for comments.
Enabled the `s escape anywhere `t is allowed. It was previously only allowed by #IfWin and (Join.
Improved load-time syntax validation of expressions.
Removed *deref operator.
Removed Object.Length (not Object.Length()) because it causes surprising behaviour with associative arrays (so does "base", but that will be addressed later). Object.Length was added in v2.0-a049 (c1196f1e).
Fixed sub-expressions like (A_WorkingDir := y) producing an unusable variable reference in some contexts.
Library Changes
Replaced ClipboardAll variable with ClipboardAll() function.
- Replaced "binary clip" var attribute with a built-in object type.
- Removed special clipboard modes of FileRead/FileAppend.
- Added general "RAW" binary mode for FileRead/FileAppend.
- Changed ClipboardAll to always use 32-bit data sizes.
Split Control, ControlGet, Drive and DriveGet sub-commands into separate functions (with some renaming).
Changed ControlChoose(N) to allow N = 0 (deselect all).
Optimized ControlGetCurrentCol().
Changed ControlGetFocus to set ErrorLevel:=0 when there's no focus.
Fixed ControlGetTab() to return 0 when no tab is selected.
Removed ControlTabLeft/ControlTabRight and added ControlSetTab.
- TabLeft/TabRight were equivalent to ControlSend with {Left/Right} after SetKeyDelay -1, 0.
- TabLeft/TabRight did not work correctly with TCS_BUTTONS.
Changed parameter order of ControlMove, ControlSend, ControlSetText, WinSetTitle and WinMove to be consistent with other functions.
Fixed DirExist(pattern) to skip over files matching the pattern.
Changed FileExist and DirExist to ignore . and .. in dir\*.* so they behave as most users would expect (for detection of empty vs. non-empty directories).
Fixed FormatTime to return strings for WDay/YDay (not pure numbers) and throw an exception if Format exceeds 2000 chars (vs. silently failing).
Changed MsgBox and InputBox to allow explicitly empty title.
Changed SoundSet and SoundGet to throw an exception for "Invalid Control Type or Component Type" (invalid parameter).
File I/O
Changed FileRead and FileAppend to be more consistent.
Code: Select all
Data := FileRead([Filename, Options])
FileAppend(Data [, Filename, Options])
; Options: "`n m1024 Encoding|RAW"
; Default to no end-of-line translation.
Changed File.ReadLine() to always recognize `r, `n and `r`n as line endings. EOL options now only affect translation of characters passed from or to the script.
Reverted FileOpen EOL options/default to how they were in v1 (with the exception of ReadLine()), for consistency with FileRead/FileAppend.
Changed File.RawRead/RawWrite to support binary strings and address_var.
- If a variable containing a pure number is passed, the number is used as an address, consistent with NumPut/NumGet.
- RawWrite can accept a binary string directly, such as one returned by ClipboardAll().Data.
- RawRead updates the variable's length to include all of the read data (rounded up to the next multiple of sizeof(TCHAR)).
Bytes (param #2) is optional when passing a binary string/variable:
- For RawWrite, it defaults to the binary string length.
- For RawRead, it defaults to the variable's capacity.
Changed A_FileEncoding to return "CP0" instead of "", because otherwise,
enc := A_FileEncoding ...
FileAppend(s, f, enc) may not have the intended effect.
Registry
Merged A_LoopRegSubKey into A_LoopRegKey (and removed the former).
Changed parameters of RegWrite/RegDelete/RegDeleteKey.
- Put Value first for RegWrite, like IniWrite.
- If the current Loop Reg item is a subkey, let the Reg functions operate on it by default (omit KeyName but specify ValueName).
- If the current Loop Reg item is a value, let the Reg functions operate on A_LoopRegKey by default.
- Let RegWrite specify a new ValueType when writing to the current Loop Reg value.
- Change RegDelete without params to never delete keys; only values.
- Let RegDeleteKey's param be omitted to delete the current key.
Documentation
New documentation has been written for most of the changes, but not all examples have been updated. The syntax shown for each function (in the yellow blocks) has been updated. The new "command" syntax is not fully documented, but neither was the old syntax.