Quotation Marks and Variables

Get help with using AutoHotkey and its commands and hotkeys
webkin32
Posts: 4
Joined: 10 Jul 2019, 20:49

Quotation Marks and Variables

10 Jul 2019, 22:02

I'm trying to use a variable in a GUI that requires the use of quotation marks. But instead of the computer using the defined variable, it is just printing the name of the variable

This is the line of code I'm having problems with (category is set to AbcTestAbc)

Code: Select all

Instruction := "The category is  %Category%"
but instead of it saying "The category is AbcTestAbc" it says "The category is %Category%

Please Help. Thanks in advance
User avatar
Datapoint
Posts: 68
Joined: 18 Mar 2018, 17:06

Re: Quotation Marks and Variables

10 Jul 2019, 23:21

try

Code: Select all

Instruction := "The category is " Category
:arrow: https://www.autohotkey.com/docs/Variables.htm#Intro

Code: Select all

MyNumber := 123
MyString := "This is a literal string."
CopyOfVar := Var  ; Unlike its counterpart in the previous section, percent signs are not used with the := operator.
User avatar
JoeWinograd
Posts: 1268
Joined: 10 Feb 2014, 20:00

Re: Quotation Marks and Variables

11 Jul 2019, 00:10

Hi webkin,
What you're looking for is concatenation, documented here:

https://www.autohotkey.com/docs/Variables.htm#concat

The period (dot) is the concatenation operator. As the doc says, there are times when it can be omitted and times when it can't be, but I always prefer to include it for consistency in my coding. So, in the line of code you posted, it would be:

Code: Select all

Instruction:="The category is " . Category
Also, study the doc on Expressions and Operators in Expressions. Regards, Joe
webkin32
Posts: 4
Joined: 10 Jul 2019, 20:49

Re: Quotation Marks and Variables

11 Jul 2019, 07:57

Thank you this solved my problem.
You're all amazing :D
User avatar
JoeWinograd
Posts: 1268
Joined: 10 Feb 2014, 20:00

Re: Quotation Marks and Variables

11 Jul 2019, 10:01

You're welcome. Glad to hear that fixed it for you. Regards, Joe

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], kyuuuri and 259 guests