I have a GUI that requires you to click some randomly generated pictures. The random generator produces a string of numbers (I'm calling it a seed) so that you can reuse those pictures if needed in the exact order.
So for example there is 5 pictures. 3 pictures display on screen. A current seed is produced with maybe 4,1,5. (picture 4 on the left, 1 in the middle, 5 on the right).
I'm working on an input box that will accept a new seed in the format x,y,z. How would I parse through the new seed (input from the input box) to add picture x, y, and z to the GUI?
I know I could create a new variable for each piece of the new seed, but I'm not sure how to get each part of it separated by a comma into a variable.
Some sample code:
Code: Select all
#warn
#noenv
Gui, Add, Button, x450 y29 w100 h30 , Seed
Gui, Add, Button, x232 y430 w100 h30, Start
Gui, Color, FFFFFF
Gui, Show, x189 y87 h630 w563, GuiWindowName
Return
ButtonStart
x = 0
while x < 4
{
x += 1 ;runs through loop until there are 24 boxes, then runs the 25th loop command
if x = 1
{
a = 12 ;coords
y = 79
}
if x = 2
{
a = 122
y = 79
}
if x = 3
{
a = 232
y = 79
}
if x = 4
{
return
}
{
Random, Choice%x%, 1, 3
Seed%x% := Choice%x%
if Choice%x% = 1
{
Gui, Tab, Game
Gui, Add, Picture, x%a% y%y% w100 h100 gPhoto%x%, %A_WorkingDir%\resources\photo1.jpg
}
if Choice%x% = 2
{
Gui, Tab, Game
Gui, Add, Picture, x%a% y%y% w100 h100 gPhoto%x%, %A_WorkingDir%\resources\photo2.jpg
}
if Choice%x% = 3
{
Gui, Tab, Game
Gui, Add, Picture, x%a% y%y% w100 h100 gPhoto%x%, %A_WorkingDir%\resources\photo3.jpg
}
}
}
return
ButtonSeed:
ButtonSeed:
InputBox, NewSeed, Bingo Seed, Your Seed is listed in the box. You may copy it now for later or enter a new seed.`nWould you like to enter a new seed?, , 500, 150, , , , , %Seed1%,%Seed2%,%Seed3%
return
edit2: I don't understand parse, but I saw that it suggested StrSplit was an alternative. Well it says the following variable name contains an illegal character: "1,2,3"
Using code:
Code: Select all
ButtonSeed: ; you saw this part
InputBox, blahblahblah
if ErrorLevel
MsgBox, Closing.
else
WorkingSeed := StrSplit(%NewSeed%, ",", A_Space)
MsgBox % "Your new seed is " WorkingSeed[1] WorkingSeed[2] WorkingSeed[3]
return