How do I extract values from an array for use as option in a command? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
joefiesta
Posts: 498
Joined: 24 Jan 2016, 13:54
Location: Pa., USA

How do I extract values from an array for use as option in a command?

17 Feb 2018, 11:15

I tried pseudo arrays, Select1 Select2..., and decided the code was messy and doc says don't use them!!! So, I wrote this:

Code: Select all

 select := [1,0,1,0]
   folderct := 4
   loop, %folderct%
      {
      a := select[a_index]
      gui, 98: add, checkbox, Section  checked%a%   x20    y+10   vSel%a_index%
      }
Works perfectly fine. But, I hate it. I've tried every way I can think to eliminate creating the temporary variable "A", for example:

gui, 98: add, checkbox, checked% select[A_index]


Can the Gui,Add,Checkbox command be written without first creating variable "A"?
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: How do I extract values from an array for use as option in a command?  Topic is solved

17 Feb 2018, 12:08

Try this:

Code: Select all

      gui, 98: add, checkbox, % "Section checked" select[a_index] " x20 y+10 vSel" a_index
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
joefiesta
Posts: 498
Joined: 24 Jan 2016, 13:54
Location: Pa., USA

Re: How do I extract values from an array for use as option in a command?

17 Feb 2018, 15:08

@Jeeswg:

Thanks.... works like a charm. The doc makes you think you can't use an expression in a command. I think it needs to differentiate between explicit and implicit (like above) expressions (and those stupid "IF" expressions).
SirRFI
Posts: 404
Joined: 25 Nov 2015, 16:52

Re: How do I extract values from an array for use as option in a command?

18 Feb 2018, 05:57

Because normally you can't, unless you force expression as given above. AHK 2 are all functions, therefore expression by default.
Use

Code: Select all

[/c] forum tag to share your code.
Click on [b]✔[/b] ([b][i]Accept this answer[/i][/b]) on top-right part of the post if it has answered your question / solved your problem.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: CrowexBR, haomingchen1998, mcd, Peiya, ShatterCoder, spellegrnio1 and 93 guests