FireLordZi Posted February 5, 2008 Share Posted February 5, 2008 What's wrong with my For Loop? $readsection = IniReadSection("C:\buddies.ini", "OnlineBuddies") If IsArray($readsection) Then For $z = 1 To $readsection[0][0] $var0 = StringSplit($readsection[$z][1], "~") $var1 = StringSplit($readsection[$z][1], ";") $date_ = StringTrimLeft($var1[UBound($var1)-1], 1) $dateitems = _GUICtrlListViewSetItemText($nListview, $z, 2, $date_); Sets the date from the INI file Next EndIf Here's my .ini if you need: [OnlineBuddies] Nemo=sdfgdsg|sdfgsd|dsfg;~2-5-08 Ando=fdgdfsg|dsfgsd|rfgdf;~2-3-08 It is supposed to be setting the date to both of my listview items but it only sets 2-5-08 to the second listview item. What is wrong with my code? While Alive() { DrinkWine(); }AutoIt Programmer Link to comment Share on other sites More sharing options...
martin Posted February 5, 2008 Share Posted February 5, 2008 What's wrong with my For Loop? $readsection = IniReadSection("C:\buddies.ini", "OnlineBuddies") If IsArray($readsection) Then For $z = 1 To $readsection[0][0] $var0 = StringSplit($readsection[$z][1], "~") $var1 = StringSplit($readsection[$z][1], ";") $date_ = StringTrimLeft($var1[UBound($var1)-1], 1) $dateitems = _GUICtrlListViewSetItemText($nListview, $z, 2, $date_); Sets the date from the INI file Next EndIf Here's my .ini if you need: [OnlineBuddies] Nemo=sdfgdsg|sdfgsd|dsfg;~2-5-08 Ando=fdgdfsg|dsfgsd|rfgdf;~2-3-08 It is supposed to be setting the date to both of my listview items but it only sets 2-5-08 to the second listview item. What is wrong with my code? Don't know, but it looks like you should be saying $dateitems = _GUICtrlListViewSetItemText($nListview, $z-1, 2, $date_); Sets the date from the INI file Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
weaponx Posted February 5, 2008 Share Posted February 5, 2008 You should be splitting by semi-colon first, then stripping. sdfgdsg|sdfgsd|dsfg;~2-5-08 [1] = sdfgdsg|sdfgsd|dsfg [2] = ~2-5-08 StringTrimLeft(1....) Link to comment Share on other sites More sharing options...
FireLordZi Posted February 5, 2008 Author Share Posted February 5, 2008 Thanks, both of your replies helped. While Alive() { DrinkWine(); }AutoIt Programmer Link to comment Share on other sites More sharing options...
FireLordZi Posted February 10, 2008 Author Share Posted February 10, 2008 Don't know, but it looks like you should be saying $dateitems = _GUICtrlListViewSetItemText($nListview, $z-1, 2, $date_); Sets the date from the INI file Ok, I did this and now it is setting the date to the first listview item. For example, if there are three items, and two items have dates, no matter where the items are, it will set both dates in the first and second listview item. This code is not working properly, any suggestions? While Alive() { DrinkWine(); }AutoIt Programmer Link to comment Share on other sites More sharing options...
FireLordZi Posted February 10, 2008 Author Share Posted February 10, 2008 bump While Alive() { DrinkWine(); }AutoIt Programmer Link to comment Share on other sites More sharing options...
andybiochem Posted February 11, 2008 Share Posted February 11, 2008 (edited) Ok, I did this and now it is setting the date to the first listview item.For example, if there are three items, and two items have dates, no matterwhere the items are, it will set both dates in the first and second listview item.This code is not working properly, any suggestions?I think your problem is with your loop setup and this line:_GUICtrlListViewSetItemText($nListview, $zListView items are ZERO-BASED and thus your $z needs at some point to = 0 to set the first ListView item (index = 0)I think that's what martin was trying to get at?if there are three items, and two items have dates, no matterwhere the items are, it will set both dates in the first and second listview item.this is because you are simply assigning the text to whatever $z is - which at the moment is 0 and 1 (using $z - 1). You're not telling autoit which listview item is the one you want to set the date to. In my experience it's easier to re-write the whole list view from scratch every time you want to update things, otherwise you'd need to script to look for the correct listview item text (e.g. Nemo or Ando etc) get the index of that item then assign the date by that index.Much easier to re-write the listview with the new date imo. Edited February 11, 2008 by andybiochem - Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now