The input issue between dictionary Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
dsewq1LYJ
Posts: 116
Joined: 26 Aug 2014, 23:21

The input issue between dictionary

20 Aug 2018, 21:07

Hi Guys

Today I met a problem.

If you try to using "Input" command to retrieve the user input.

The command always treat "0 to 9"(digits) as "Integer".
You can check it with

Code: Select all

Input,foo,L1
if foo is integer
  ToolTip ...it's an integer
and if you try to use the output(digits) for a dictionary, that's definitely won't work.

e.g.

Code: Select all

dict = {}
dict.Insert("1", "foo")

Input,uin,L1
ToolTip dict[uin] ; It's same as dict[1], not dict["1"]
so I try to solve this problem by some trick.
Try to fool the interpreter force to convert Integer into String.

1. Not work

Code: Select all

Input,uin,L1
uin := uin ""
2. Not work

Code: Select all

Input,uin,L1
uin := uin . ""
3. Not work

Code: Select all

Input,uin,L1
uin := uin " "
StringTrimRight,uin,uin,1
...all of those methods just not working.
Is it possible solve this cleanly?
gregster
Posts: 9001
Joined: 30 Sep 2013, 06:48

Re: The input issue between dictionary  Topic is solved

20 Aug 2018, 21:22

Tricky, but this works:

Code: Select all

dict := {"1": "foo"}
Input,uin,L1
msgbox % dict["" uin ""] 
ExitApp
Two " in an expression ("") create a literal " . With the integer in between you can create a string... and this gets you dict["1"]
dsewq1LYJ
Posts: 116
Joined: 26 Aug 2014, 23:21

Re: The input issue between dictionary

20 Aug 2018, 21:52

gregster wrote:Tricky, but this works:

Code: Select all

dict := {"1": "foo"}
Input,uin,L1
msgbox % dict["" uin ""] 
ExitApp
Two " in an expression ("") create a literal " . With the integer in between you can create a string... and this gets you dict["1"]
Damn man.

Well done. Cool sheep
:dance:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, JoeWinograd, mikeyww, Nerafius, Spawnova and 105 guests