for the sake of this question, lets assume that I have images with these names in a certain folder: buttonA.bmp, buttonA2.bmp, buttonA3.bmp, buttonB.bmp, buttonB2.bmp.
I am trying to create an associative array at the beginning of my script, which will read the names of pictures and create an array of them so that my script can know "by itself" how many images of certain things are there. I am trying to make it work this way because right now, whenever i create a new picture, lets say buttonB3.bmp, I need to add some code in my script so that it would include the newly added picture in the search for buttonB. And its becoming quite cumbersome. So the way I tried to make it work was like this:
Code: Select all
class ButtonPictures
{
__new()
{
IniRead, sectionNames, files\buttons.ini ;i have the names of all buttons in buttons.ini
Loop, parse, sectionNames, `n ;retrieves the name of each button
{
secName := A_LoopField
Loop, Files, files\%secName%??.bmp ;searches for all images starting with buttons name
{
%secName% := {(a_index): A_LoopFileName} ;this is what confuses me and is probably the core of the failure
msgbox, % %secName%[a_index] ;this works as expected, shows the name of the image
}
msgbox, % %secName%[1] ;this does not show anything
}
msgbox, % buttonA[2] ;this also does not show anything
}
}
Code: Select all
this.
Code: Select all
this.%secName%
So, again, my question is: what should I need to change in the code above to successfully create an associative array where the name of the button is the name of array, keys are just integers and values are the names of pictures. For example:
Code: Select all
buttonA{1: buttonA.bmp, 2: buttonA2.bmp, 3: buttonA3.bmp}
Thank you in advance
![Smile :)](./images/smilies/icon_e_smile.gif)