Archive: nsArray loop Counter? or any loop counter at all?


nsArray loop Counter? or any loop counter at all?
Hi guys, I've been using NSIS for a about a week now but I seem to have come across a problem:

Basically, I currently have an array (using nsArray) with some key/values e.g.



nsArray::SetList MyArray1 /key=key1 "val 1" /key=key2"some val 2" /key=key5949 "another value" etc


Then I would do something like this to foreach through it and apply each value to an nsDialog dropdownlist:

   
${ForEachIn} MyArray1 $R0 $R1
${NSD_CB_AddString} $DropDownList"$R1"
${Next}


My problem is, I want to then use:


SendMessage $DropDownList${CB_SETITEMDATA} $drop_list_index $itemdatavalue


in the foreach loop and have each drop list have their own itemdatavalue related to the key in the array, but I also need to have an indexer of some sort so i can apply each itemdatavalue accordingly.

I am really struggling on thinking of a way of accomplishing this, and I have even looked at using the loglib 'for' loop, but I wasn't having much luck.

Any help would be greatly appreciated.

StrCpy $R2 0
${ForEachIn} MyArray1 $R0 $R1
${NSD_CB_AddString} $DropDownList "$R1"
SendMessage $DropDownList ${CB_SETITEMDATA} $R2 $itemdatavalue
IntOp $R2 $R2 + 1
${Next}
Stu

wow, thank you so much Stu, it worked perfectly! yay :)