Since V2 removed "=" assignment, I cannot use the following code.
var =
(
line1
line2
line3
}
but the replacement which I know is too complex. such as:
var := "line1`n"
. "line2`n"
. "line3`n"
Who can tell me a simple one?
Thanks.
assignment in V2
Re: assignment in V2
This works in 1.1
Code: Select all
var :=
(
"This is a string.
that is a very long string
and it spans multiple
lines. "
)
MsgBox, % var
Re: assignment in V2
Thanks, but V2 does not support this format.trismarck wrote:This works in 1.1Code: Select all
var := ( "This is a string. that is a very long string and it spans multiple lines. " ) MsgBox, % var
Re: assignment in V2
This works for me
Code: Select all
s := "
(
Begin
continuation
section
)"
Msgbox %s%
Re: assignment in V2
Code: Select all
Assign, var,
(
line1
line2
line3
)
Assign(p) {
return p
}
Re: assignment in V2
It just needs the Q option, so that the second quote mark is interpreted as a close-quote.isurface wrote:Thanks, but V2 does not support this format.
Code: Select all
var :=
(Q
"This is a string.
that is a very long string
and it spans multiple
lines. "
)
MsgBox, % var
Re: assignment in V2
Thanks all, they are just what I wanted.
Hi Jethrow,
Could you explain this a bit more? What's "comma" means here? I have never seen this syntax.
Hi Jethrow,
Could you explain this a bit more? What's "comma" means here? I have never seen this syntax.
jethrow wrote:Code: Select all
Assign, var, ( line1 line2 line3 ) Assign(p) { return p }
Re: assignment in V2
User-defined function(s) in v2 can be called in command syntax. jethrow defined an assign function and called it in command syntax. Since the function is returning a value, calling it in command syntax requires an OutputVar, in this case var. Comma is needed as it requires 2 parameters: OutputVar and Value(value to assign). You can omit the first comma after assign as AHK has smart comma handling
Last edited by Coco on 02 Nov 2013, 01:32, edited 1 time in total.
Re: assignment in V2
It's one of the new amazing features of AHK v2 - any function can be called as a command, and any command can be called as a function. Really, they are just executable statements. So, the following are 2 statements are equivalent:isurface wrote:Could you explain this a bit more? What's "comma" means here? I have never seen this syntax.
Code: Select all
var := Assign("value")
Assign, var, value
Assign(p) {
return p
}
Re: assignment in V2
Amazing, very concise. It looks like ASM.
Code: Select all
add, var, 2, 3
add(p, q) {
return p + q
}
Who is online
Users browsing this forum: ntepa and 59 guests