Obsolete test build - Some v2 features in v1

Community news and information about new or upcoming versions of AutoHotkey
lexikos
Posts: 6207
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Obsolete test build - Some v2 features in v1

13 Mar 2015, 22:36

OBSOLETE: Get v1.1.21 instead.
v1.1.20.02-5+g6fdd7fa
Changes:
  • Added Loop Files and Loop Reg sub-commands as in v2.

    Code: Select all

        Loop, Reg, RootKey[\Key, Mode]
        Loop, Files, FilePattern [, Mode]
        
        Mode:
          K or D -- include keys/directories
          V or F -- include values/files
          R -- recurse
  • Changed the parser to allow % expression for InputVar args of Loop Parse, SplitPath and String commands. This is primarily for Loop Parse, so that Loop Parse, % var will work in both v1 and v2 (whereas var in Loop Parse, var is interpreted as a literal string in v2).
  • Revised Object methods.

    Code: Select all

    ; Derived from Insert:
    Object.InsertAt(Index, Value1 [, Value2, ...])
    Object.Push(Value1 [, Value2, ...])
    ObjRawSet(Object, Key, Value)
    
    ; Derived from Remove:
    Value := Object.RemoveAt(Index)
    Value := Object.Delete(Key)
    Value := Object.Pop()
    
    ; New:
    Length := Object.Length()  ; Returns Object.MaxIndex() if > 0, otherwise returns 0.
    Insert and Remove are deprecated.
v1.1.20.02-9+g9996e86

Added Ord() and StrReplace().
Updated Chr(), RegRead, RegWrite and RegDelete.
Details in a later post.

Background info:
Coco
Posts: 771
Joined: 29 Sep 2013, 20:37
GitHub: cocobelgica

Re: New test build - Some v2 features in v1

13 Mar 2015, 22:49

Nice. Loop, Parse, % expression is really convenient. Btw, will you also consider Backport v2 quoted literal "strings"/'strings' duality.? You did mention it here.
lexikos
Posts: 6207
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: New test build - Some v2 features in v1

13 Mar 2015, 23:15

As implied by omission from my previous post, I do not plan to implement it. I would either need to port a considerable amount of refactored code and modify it to be backward-compatible, or re-implement it all over again. Just allowing single quotes wouldn't be difficult, but it wouldn't be compatible with v2 without also allowing variable references in the single-quoted string.
Coco
Posts: 771
Joined: 29 Sep 2013, 20:37
GitHub: cocobelgica

Re: New test build - Some v2 features in v1

13 Mar 2015, 23:29

I understand. Would allowing escaping of " as `" within quoted literal strings present the same challenges above? An error is thrown currently in v1.1+, so it should be backwards compatible. I never understood why Chris opted with "" as escaping.

Edit:
By allowing at the least the `" escaping (and promoting its usage moving forward), scripts written from here on out, will be more future-proof. Just my stance in relation to the request.
lexikos
Posts: 6207
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: New test build - Some v2 features in v1

15 Mar 2015, 00:39

v1.1.20.02-9+g9996e86
  • Added Ord():
    On Unicode builds, it returns a Unicode code point -- so it differs from Asc() only if the first two UTF-16 code units represent a supplementary character (>0xFFFF).
    On ANSI builds, it is equivalent to Asc().
  • Updated Chr() to support values >0xFFFF on Unicode builds.
  • Added StrReplace() as in v2.
  • Added backward/forward-compatible RootKey\SubKey syntax to Reg commands. If no slash is present, SubKey must be present as a separate parameter as in previous versions (but can be empty).
  • Removed the obsolete and undocumented 5-parameter mode of RegRead, which was exclusively for AutoIt compatibility (the extra parameter was never used).

Code: Select all

Output := StrReplace(Input, SearchText [, ReplaceText, OutputVarCount, Limit])

; Use RootKey\SubKey instead of RootKey, SubKey:
RegRead, OutputVar, RootKey\SubKey, ValueName
RegWrite, ValueType, RootKey\SubKey, ValueName, Value
RegDelete, RootKey\SubKey, ValueName

; Use \\ComputerName\ (slash) instead of \\ComputerName: (colon):
RegRead, OutputVar, \\ComputerName\RootKey\SubKey, ValueName
RegWrite, ValueType, \\ComputerName\RootKey\SubKey, ValueName, Value
RegDelete, \\ComputerName\RootKey\SubKey, ValueName

; Use a trailing slash to access the RootKey itself:
RegRead v, RootKey\, ValueName

; Equivalent to RootKey\ in v1 but not v2:
RegRead v, RootKey,, ValueName

; Equivalent to RootKey\ in v2, but not v1:
RegRead v, RootKey, ValueName

; ValueName and Value can be omitted.
The benefits of this syntax are:
  • RootKey\SubKey can be contained within a single variable.
  • Easier copy-paste from other sources, such as the internet or regedit.
Note that in a registry loop, these commands support an additional syntax mode which isn't affected by these changes:

Code: Select all

RegRead OutputVar  ; Reads the current loop item.
RegWrite Value  ; Writes the current loop item.
RegDelete  ; Deletes the current loop item.
ahk7
Posts: 127
Joined: 06 Nov 2013, 16:35

Re: New test build - Some v2 features in v1

15 Mar 2015, 04:00

In v1.1.20.02 and earlier the code below worked, with v1.1.20.02-9+g9996e86 64-bit it gives an error "Unexpected %"

Code: Select all

o:={ext:"a,b,c"}
MsgBox % o.ext
test:="b"

If test in % o.ext ; v1.1.20.02-9+g9996e86 gives Error: Unexpected %
	MsgBox Found
lexikos
Posts: 6207
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: New test build - Some v2 features in v1

15 Mar 2015, 04:47

Fixed in v1.1.20.02-10+gef256dc.
User avatar
jNizM
Posts: 2343
Joined: 30 Sep 2013, 01:33
GitHub: jNizM
Contact:

Re: New test build - Some v2 features in v1

19 Mar 2015, 05:46

Just for reference AHK v1.1.20.XX
A_OSVersion and latest Win10 Build (10041)
Image

Thanks again for implement
[AHK] 1.1.30.01 x64 Unicode | [WIN] 10 Pro (Version 1803) x64 | [GitHub] Profile
Donations are appreciated if I could help you

Return to “Announcements”

Who is online

Users browsing this forum: No registered users and 2 guests