square brackets in variable value

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
obob
Posts: 9
Joined: 01 Jul 2021, 04:41

square brackets in variable value

28 Sep 2021, 04:34

Is there an issue with square brackets in string passed to a variable in if and switch statements?
When I pass a string containing square brackets to switch or if statements, it does not get evaluated,
when I pass string without square brackets the same switch and if, it works as expected.

Does anyone know what is going on?
User avatar
mikeyww
Posts: 26944
Joined: 09 Sep 2014, 18:38

Re: square brackets in variable value

28 Sep 2021, 05:13

Yes, you probably have a bug in your syntax. You could post your script for feedback.
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: square brackets in variable value

28 Sep 2021, 10:22

Code: Select all

string := "[mybrackets]"

if (string = "[mybrackets]")
    MsgBox,, if, % string

switch string
{
    case "[mybrackets]":MsgBox,, switch, % string
    Default:MsgBox ?
}
obob
Posts: 9
Joined: 01 Jul 2021, 04:41

Re: square brackets in variable value

28 Sep 2021, 19:10

thank you guys. Not sure, why it did not work in my script. It works now.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Araphen, Insanibaccha and 229 guests