1
votes

I have decided to have an accompanying .ini file with an executable so that I do not have to hard code items that appear in a drop down menu. I have created the .ini file and using the IniReadSection function I have been able to look through the section and output each Key=Value pair within that section.

How would I go about placing the value's only into a string array? I am writing this utility using AutoIT.

1

1 Answers

3
votes

I made this ini file:

[JHamill]
key1=value1
key2=value2
key3=value3

I took a bit of code from IniReadSection example and modified this to be able to use it for a drop down menu.

$var = IniReadSection("test.ini", "JHamill")

$str = ""
For $i = 1 To $var[0][0]
    $str &= $var[$i][1] & "|"
Next
$str = StringTrimRight($str, 1)

GUICreate("JHamill GUI combo")

GUICtrlCreateCombo("", 10, 10)
GUICtrlSetData(-1, $str)

GUISetState()

While 1
    $msg = GUIGetMsg()

    If $msg = -3 Then ExitLoop
WEnd

Here you see you don't have to make a new array to make it work. But since you asked, here is the same thing by making a new array first, copying only the value elements, and then using that array to fill the combo box:

#include <Array.au3>

$var = IniReadSection("test.ini", "JHamill")

Local $arr[$var[0][0]]
For $i = 1 To $var[0][0]
    $arr[$i-1] = $var[$i][1]
Next
_ArrayDisplay($arr)