Page 1 of 1

syntax with referenced variables

Posted: 13 Feb 2018, 06:34
by Danniique
I've been trying to adopt this line of code I found elsewhere on the AHK forums:

Code: Select all

	Send % m ?"{Volume_Up}":"{Volume_Down}"

Into something along the lines of:

	send % "{Volume_Up}"

which works fine, but using a referenced variable, like:

	Vu={Volume_Up}
	send % "%Vu%"

but this just sends the raw text %Vu%, so I try instead perhaps swapping the quotes to be included with the variable:

	Vu="{Volume_Up}"
	send % %Vu%
but this still doesn't work, with the error saying it contains Illegal characters, yet when I inspect the variable it contains what I want it to. I've tried heaps of other variations but I just can't get it to work.

Is it even possible to do?

Re: syntax with referenced variables  Topic is solved

Posted: 13 Feb 2018, 07:11
by Blackholyman
try this

Code: Select all

	Vu:="{Volume_Up}"
	send %Vu%

	Vu:="{Volume_Up}"
	send % Vu

	Vu={Volume_Up}
	send %Vu%

Re: syntax with referenced variables

Posted: 13 Feb 2018, 11:31
by Danniique
Blackholyman wrote:try this

Code: Select all


Vu:="{Volume_Up}"
	send % Vu
	
Thank you Blackholyman!

So, the problem as you have no doubt seen was my use of the = equals operator instead of the := assign operator. I must say though, I'm a bit confused though as to why assign work and equals doesn't.
As your other two examples show, when not forcing the expression in the Send command with send % [...], both operators work equally. Grrrr. I can't believe one little : sign ended up costing me so much time.

On second thoughts, yes, I can believe it; otherwise debugging wouldn't be the endless party that puts the F in your Fun all night long.