jackal07 Posted March 3, 2008 Posted March 3, 2008 Can someone help me out with this? Below I create images next to each listview item. Depending on whether the buddy (listview item) is online or offline it creates a separate image. It reads if the buddy is offline or online from an .ini file. My problem is it is creating an online image to every item, even the items that are offline. I think it has something to do with the way I create each listview item and the for loop. Can someone help? ; nListview; Global $array Global $val Global $items _GUICtrlListView_DeleteAllItems($nListview); Deletes all items from the topmost listview $varBuddies = INIRead("C:\buddies.ini", "BuddyList", "Buddies", "Unable to read INI.") $array = StringSplit($varBuddies, ";"); Splits the string up by using commas as delimiters _ArrayDelete ( $array, 0 ) $readsection = IniReadSection("C:\buddies.ini", "OnlineBuddies"); Reads the online section For $i = 0 To Ubound($array) - 1 If $array[$i] <> "" Then $items = GUICtrlCreateListViewItem("|" & $array[$i], $nListview); Creates the listview items from the INI file If IsArray($readsection) Then For $z = 1 To $readsection[0][0] If $readsection[$z][0] = $array[$i] Then $var0 = StringSplit($readsection[$z][1], "~"); splits by ~ $var1 = StringSplit($readsection[$z][1], ";"); splits by; $date_ = StringTrimLeft($var1[UBound($var1)-1], 1) $dateitems = _GUICtrlListView_SetItemText($nListview, $i, $date_, 2); Sets the date from the INI file Else EndIf If StringInStr($readsection[$z][1], "+On") Then; If the buddy is online GUICtrlSetImage($items, "pic42.bmp", -138); Sets an online image Else GUICtrlSetImage($items, "pic37.bmpl", -110); Sets an offline image EndIf Next EndIf Next
smashly Posted March 4, 2008 Posted March 4, 2008 Wonder how long before SmOke_N will catch your nick.. Buwahaha Last I looked you had been permanently banned for evading a ban and creating multiple accounts. 1st Problem GUICtrlSetImage($items, "pic37.bmpl", -110) .. "pic37.bmpl" , shouldn't that be "pic37.bmp" ? 2nd problem is the way your using GUICtrlSetImage($items, "pic42.bmp", -138)... What's the -138 for? Your setting an image that's a bmp , not calling an image from a dll or a resource that contains multiple images.
jackal07 Posted March 4, 2008 Author Posted March 4, 2008 Its not the images. These are just typos in autoitscript. They are perfect in my code. I know something is wrong with my for loop. When I was testing it would change the name of the buddy being read from the ini file...BUT it would stay on the same buddy from $array[$i] meaning i will have to do something about the for loop structure. Any ideas? I tried doing this but I get errors: ; nListview; Global $array Global $val Global $items _GUICtrlListView_DeleteAllItems($nListview); Deletes all items from the topmost listview $varBuddies = INIRead("C:\buddies.ini", "BuddyList", "Buddies", "Unable to read INI.") $array = StringSplit($varBuddies, ";"); Splits the string up by using commas as delimiters _ArrayDelete ( $array, 0 ) $readsection = IniReadSection("C:\buddies.ini", "OnlineBuddies"); Reads the online section For $i = 0 To Ubound($array) - 1 If $array[$i] <> "" Then $items = GUICtrlCreateListViewItem("|" & $array[$i], $nListview); Creates the listview items from the INI file Next If IsArray($readsection) Then For $z = 1 To $readsection[0][0] If $readsection[$z][0] = $array[$i] Then $var0 = StringSplit($readsection[$z][1], "~"); splits by ~ $var1 = StringSplit($readsection[$z][1], ";"); splits by; $date_ = StringTrimLeft($var1[UBound($var1)-1], 1) $dateitems = _GUICtrlListView_SetItemText($nListview, $i, $date_, 2); Sets the date from the INI file Else EndIf msgbox(0, "", $readsection[$z][0]) msgbox(0, "", $array[$i]) If $readsection[$z][0] = $array[$i] Then msgbox(0, "", $readsection[$z][1]) If StringInStr($readsection[$z][1], "+On") Then; If the buddy is online GUICtrlSetImage($items, "shell32.dll", -138); Sets an online image Else GUICtrlSetImage($items, "shell32.dll", -110); Sets an offline image EndIf Else GUICtrlSetImage($items, "shell32.dll", -110); Sets an offline image EndIf Next EndIf
Moderators SmOke_N Posted March 4, 2008 Moderators Posted March 4, 2008 Keep it up JesusIsKing, FireLord, FireLordZi, Ozi, chssoccer, etc... If you put half the time in learning how to code as you do coming up with new accounts.... You wouldn't have to ask so many medial questions. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Recommended Posts