Code: Select all
; Explicit concatenation
msgBox % var . "bar"
; Implicit concatenation
; Less visual noise - good. But there are probably some cases when it's not a good idea to use it?
msgBox % var "bar"
Code: Select all
; Explicit concatenation
msgBox % var . "bar"
; Implicit concatenation
; Less visual noise - good. But there are probably some cases when it's not a good idea to use it?
msgBox % var "bar"
Code: Select all
; Explicit concatenation
msgBox % var . "bar"
. "`n..."
Good point! So, with explicit concatenation the code is consistent everywhere.Flipeador wrote:You must also use it when you split the string into several lines
100%MaxAstro wrote:It's much more clear what is going on if someone else reads my code. And if I haven't looked at a piece of code in three months, then I qualify as "someone else", too.
Code: Select all
;Style 1
WebRequest.Open("GET","http://" Host "/cm?cmnd=" Command State (user ? "&user=" UriEncode(user) "&password=" UriEncode(pass) : ""),0)
;Style 2
WebRequest.Open( "GET", "http://" . Host . "/cm?cmnd=" . Command . State . (user ? "&user=" . UriEncode(user) . "&password=" . UriEncode(pass) : "" ), 0 )
;Style 3
Method := "GET"
Uri := "http://" . Host . "/cm?cmnd=" . Command . State
If ( User ){
eUser := UriEncode(user)
Uri := Uri . "&user=" . eUser
ePass := UriEncode(pass)
Uri := Uri . "&password=" . ePass
}
WebRequest.Open( Method, Uri )
Code: Select all
;Is the '.' useful? Perhaps not.
MsgBox, % var "text" var var "text" "text" var "text"
MsgBox, % var . "text" . var . var . "text" . "text" . var . "text"
Code: Select all
;initial commas
MouseGetPos, vCurX, vCurY, hWnd, vCtlClassNN
MouseGetPos,,, hWnd, vCtlClassNN
;no initial commas
MouseGetPos vCurX, vCurY, hWnd, vCtlClassNN
MouseGetPos ,, hWnd, vCtlClassNN
Code: Select all
A := "Hello"
B := "World"
C := (A)(A_Space)(B)
MsgBox % C
Thanks.
Code: Select all
A := "Hello"
B := "World"
MsgBox Format("{}{}{}",A,A_Space,B)
Code: Select all
fpath := "C:\Program Files\AutoHotkey\AutoHotkey.exe" ; insert .old before extension
SplitPath, fpath, OutFileName, OutDir, OutExtension, OutNameNoExt
MsgBox % OutDir . "\" . OutNameNoExt . ".old" . "." . OutExtension
MsgBox % Format("{}\{}.{}.{}",OutDir,OutNameNoExt,"old",OutExtension) ; work around
metoo.On topic: I prefer explicit concatenation
You can omit the dots . (A)(A_Space)(B) looks very odd to me, I think it is also harder to type than A . A_Space. B and longer than A A_Space B.Any workaround
Return to “Off-topic Discussion”
Users browsing this forum: No registered users and 65 guests