Variable using a variable

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Eddio 0141
Posts: 17
Joined: 12 Jul 2017, 13:40

Variable using a variable

22 Jul 2017, 15:23

I'm trying to make a variable name with a variable like this

Code: Select all

linenum = 1
string = %line %linenum% %
but it gives me error and doesn't work
any suggestions? thanks
User avatar
derz00
Posts: 497
Joined: 02 Feb 2016, 17:54
Location: Middle of the round cube
Contact:

Re: Variable using a variable

22 Jul 2017, 15:41

In my opinion, use expression syntax. Look up := in the help file.

Code: Select all

linenum := 1
string := "line " . linenum
Not sure why you have percent signs in the last line. That would be referencing a variable named "line 1 ". But I don't think your syntax is correct enough to do that.
try it and see
...
User avatar
divanebaba
Posts: 813
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: Variable using a variable

22 Jul 2017, 15:45

Hi.
You can not use space char in your variable.
Try this:

Code: Select all

linenum = 1
string = line%linenum%
Content of the variable string will be line1.
If the content of string has to be the content of the variable line1, use

Code: Select all

linenum = 1
string := line%linenum%
Edit: derz00 made correct. In a string you can use space char. I thought, you want to use a variable storing in another variable. Now you can choose what to do. :D
Einfach nur ein toller Typ. :mrgreen:
Eddio 0141
Posts: 17
Joined: 12 Jul 2017, 13:40

Re: Variable using a variable

22 Jul 2017, 16:20

oh wow thanks everyone :D
my problem is solved

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: lechat and 137 guests