How to... Multiple check boxes and variables. Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
burton2
Posts: 21
Joined: 18 Sep 2017, 10:20

How to... Multiple check boxes and variables.

17 Dec 2017, 14:49

What i am trying to do is... Read an xml file looking for the word <Title>. When it finds that word add a check box to a gui along with a that line of text. I want to assign it a variable then display the check boxes:

Code: Select all

Gui, +AlwaysOnTop
Gui, Add, Button, x0 y0 h50 w50 gSubmit
Loop, read, %A_ScriptDir%\Movie.xml,

{
    
    IfInString, A_LoopReadLine, <Title>, GoSub, AddCheck
    IfInString, A_LoopReadLine, <Trailer>, break
}

Gui, Show
Return

Submit:
Gui, Submit, Nohide
GuiControlGet, NEED-VAR?
If (NEED-VAR = 0)
	{
	msgbox none
	}
Else
	{
	msgbox NEED-VAR?
	}
pause

AddCheck:
{
Gui, Add, CheckBox, NEED-VAR?, %A_LoopReadLine%
}
Return
Could someone please tell me what is the best way to store multiple lines of text. Is it an array or index or fileappend. If its not to much trouble could you please point me towards or write me a quick example on how to store and retrieve the line of text.

My idea with the code above was to store each line in a check box variable. But I would need something like a loop iteration +1* for the variable but I dont know how to implement it or if it would even work as it could be hundreds, maybe thousands of lines.

I hope im not asking to much.

EDIT* I misunderstood what loop iteration is...

Code: Select all

Gui, +AlwaysOnTop
Gui, Add, Button, x0 y0 h50 w50 gSubmit

LineText := []

Loop, read, %A_ScriptDir%\Movie.xml,

{
    
    IfInString, A_LoopReadLine, <Title>, GoSub, AddCheck
    IfInString, A_LoopReadLine, <Trailer>, break
}

Gui, Show, h300 w300
Return

Submit:
Gui, Submit, Nohide
GuiControlGet, NEED-VAR?
If (NEED-VAR = 0)
	{
	msgbox none
	}
Else
	{
	msgbox ALL BOXES CHECKED?
	}
pause
 

AddCheck:
{
LineText.Insert(A_LoopReadLine)

Gui, Add, CheckBox, NEED-VAR? , %A_LoopReadLine%
}
Return
I can display in a msgbox LineText.1 or LineText.2. How do I display all LineTexts that have had the box checked? or how do I have the checkbox variable use 1,2,3 and so on without having to add hundreds of Gui,Add,CheckBox?
Osprey
Posts: 453
Joined: 18 Nov 2017, 05:50

Re: How to... Multiple check boxes and variables.  Topic is solved

17 Dec 2017, 16:46

This might do it:

Code: Select all

Gui, +AlwaysOnTop
Gui, Add, Button, x0 y0 h50 w50 gSubmit

LineText := []

Loop, read, %A_ScriptDir%\Movie.xml,
{
    IfInString, A_LoopReadLine, <Title>, GoSub, AddCheck
    IfInString, A_LoopReadLine, <Trailer>, break
}

Gui, Show, h300 w300
Return

Submit:
  Gui, Submit, Nohide

  Loop % LineText.length()
    If Title%A_Index% = 1
      AllLines .= LineText[A_Index] . "`n"

  MsgBox, %AllLines%
  AllLines := ""
Return

AddCheck:
  LineText.Insert(A_LoopReadLine)
  LineNum := LineText.length()

  Gui, Add, CheckBox, vTitle%LineNum%, %A_LoopReadLine%
Return
burton2
Posts: 21
Joined: 18 Sep 2017, 10:20

Re: How to... Multiple check boxes and variables.

17 Dec 2017, 18:02

Thank you. Iv really managed to push on, now making good progress. Much appreciated.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: jameswrightesq, mikeyww, wpulford and 336 guests