Pook 0 Posted May 12, 2010 Can someone tell me what I'm doing wrong? I'm have the code below look in an INI file and pull out the first 8 computer names listed. The code then put that name into a $label on the GUI. It works fine if the INI has 8 or less computer name, but sometimes it will have more. This is when the code errors out. (show below) Error: array variable has incorrect number of subscripts Global $Label[9] = [8] Dim $aRecords Dim $item If Not _FileReadToArray($Cache_Folder & "\XXXX.ini",$aRecords) Then EndIf For $x = 1 to $aRecords[0] $NewStr = StringReplace($aRecords[$x],'"','') GUICtrlSetData($Label[$x],$NewStr ) Next Share this post Link to post Share on other sites
Spiff59 54 Posted May 12, 2010 Well, you've pretty much spelled the whole thing out yourself... You've a set number of labels (9, numbered 0 through 8) and you have a variable length ini file to load into the labels. As soon as the line-count of the ini exceeds the last defined label, blam, there is no $Label[9]. So, you could limit your loop, maybe add something like "If $aRecords[0] > 8 then $aRecords[0] = 8" before the loop. That would limit the load to only loading the first 8 lines form the .ini. Or, you could load $aRecords first, and then use the value of $aRecords[0] to define an array of labels matching the size of the ini file. Anyway... me thinks you already were on the verge of your own answer. Share this post Link to post Share on other sites
Pook 0 Posted May 12, 2010 that worked... Thanks!!! This was my try with arrays. If $aRecords[0] > 8 then $aRecords[0] = 8 Share this post Link to post Share on other sites