I think I foud some corrections for the helpfile of V2 2.0-beta.1.
Loop Parse String [, Delimiters, OmitChars]
=>
Loop Parse, String [, Delimiters, OmitChars]
FoundPos := RegExMatch(Haystack, NeedleRegEx , OutputVar, StartingPos := 1)
=>
FoundPos := RegExMatch(Haystack, NeedleRegEx , &OutputVar, StartingPos := 1)
NewStr := RegExReplace(Haystack, NeedleRegEx [, Replacement := "", OutputVarCount := "", Limit := -1, StartingPos := 1])
=>
NewStr := RegExReplace(Haystack, NeedleRegEx [, Replacement := "", &OutputVarCount := "", Limit := -1, StartingPos := 1])
ReplacedStr := StrReplace(Haystack, Needle [, ReplaceText, CaseSense, OutputVarCount, Limit])
=>
ReplacedStr := StrReplace(Haystack, Needle [, ReplaceText, CaseSense, &OutputVarCount, Limit])
[v2] Loop comma, &OutputVar Topic is solved
Re: AHK V2 Helpfile
none seem to apply
v2-changes::Loop wrote:Currently the keyword [secondary keyword (Files, Parse, Read or Reg)] can be followed by a comma, but it is not required as this is not a parameter.
that usage is neither implied nor required. u can pass a plain variable containing a VarRef just as well(ie the & is not necessarily necessary, no pun intended)varref
Last edited by swagfag on 28 Jul 2021, 16:30, edited 1 time in total.
Re: AHK V2 Helpfile
My excuses, I have done some tests and it seems indeed to work.
I just started getting used to V2.
I just started getting used to V2.
Re: AHK V2 Helpfile
no need to apologize. an untainted gaze may after all spot something others have been missing all along. or it might not. u never know. keep digging
Re: AHK V2 Helpfile
@swagfag: Could you confirm something for me?
In RegExreplace, if you enter a value in the 4th parameter, should it always have a "&" in front if it is not empty?
If that is the case, wouldn`t it be logically and user-friendly to also add a "&" before it in the syntax in the helpfile like I proposed above?
The same applies for many functions with byref variables.
NewStr := RegExReplace(Haystack, NeedleRegEx [, Replacement := "", &OutputVarCount := "", Limit := -1, StartingPos := 1])
If I do not include the & I get errors like "This variable appears to never be assigned a value." or "Parameter #4 of RegExReplace requires a variable refernce, but recieved a String/Integer..."
In RegExreplace, if you enter a value in the 4th parameter, should it always have a "&" in front if it is not empty?
If that is the case, wouldn`t it be logically and user-friendly to also add a "&" before it in the syntax in the helpfile like I proposed above?
The same applies for many functions with byref variables.
NewStr := RegExReplace(Haystack, NeedleRegEx [, Replacement := "", &OutputVarCount := "", Limit := -1, StartingPos := 1])
If I do not include the & I get errors like "This variable appears to never be assigned a value." or "Parameter #4 of RegExReplace requires a variable refernce, but recieved a String/Integer..."
Re: AHK V2 Helpfile
i think i already confirmed that
Code: Select all
#Requires AutoHotkey v2.0-beta.1
Ref := &Var
RegExMatch('abcdef', '(def)', Ref)
MsgBox Var[1]
Re: [v2] Loop comma, &OutputVar
Putting aside any other reasons to include & or not...
Suppose that you want to remove all digits in the string "abc123". Would you call RegExReplace(abc123, "") or RegExReplace("abc123", "")? If you do not include the "", you will get errors like "This variable appears to never be assigned a value." or "This variable has not been assigned a value." (Actually, the first one is a warning, not an error.)
With the current definition, if used literally, OutputVarCount should be a variable containing a VarRef, just as Haystack should be a variable containing a String.
Adding the & prefix would show at a glance what the parameter requires, and would facilitate "copy-paste coding".
If someone wants to make this change, I would support it.
I have moved and renamed the topic.
Suppose that you want to remove all digits in the string "abc123". Would you call RegExReplace(abc123, "") or RegExReplace("abc123", "")? If you do not include the "", you will get errors like "This variable appears to never be assigned a value." or "This variable has not been assigned a value." (Actually, the first one is a warning, not an error.)
With the current definition, if used literally, OutputVarCount should be a variable containing a VarRef, just as Haystack should be a variable containing a String.
Adding the & prefix would show at a glance what the parameter requires, and would facilitate "copy-paste coding".
If someone wants to make this change, I would support it.
I have moved and renamed the topic.
Re: [v2] Loop comma, &OutputVar
Loop Parse String [, Delimiters, OmitChars]
I was confused by that at first too, I think because of Parse being a "secondary keyword" for Loop, whereas in most other cases in v2 there is only a single keyword, for example WinGetClass (not Win GetClass or Win Get Class). Lexikos, any reason for choosing Loop Parse rather than LoopParse (and LoopRead, LoopReg, LoopFiles) for v2 other than similarity with v1 usage?
I was confused by that at first too, I think because of Parse being a "secondary keyword" for Loop, whereas in most other cases in v2 there is only a single keyword, for example WinGetClass (not Win GetClass or Win Get Class). Lexikos, any reason for choosing Loop Parse rather than LoopParse (and LoopRead, LoopReg, LoopFiles) for v2 other than similarity with v1 usage?
I like that.
It could help me in training my brain from v1 to v2 to hear about such reasons and especially if there are some cases where it is better coding practice to pass a variable containing a VarRef rather than passing &MyVar as e.g. OutputVarCount argument in RegExReplace.
Re: [v2] Loop comma, &OutputVar Topic is solved
Changes added in PR #492.
Return to “Suggestions on Documentation Improvements”
Who is online
Users browsing this forum: No registered users and 5 guests