geezery Posted June 11, 2007 Share Posted June 11, 2007 I need help splitting my string it to three pieces and to put those in the list element. I managed to split it on two pieces, but I didn't figure how I can split string to three pieces. String: 10.6.2007 0:00;192.168.1.1;text in here Delimiter is ; like in csv. Link to comment Share on other sites More sharing options...
poisonkiller Posted June 11, 2007 Share Posted June 11, 2007 (edited) $var = StringSplit("10.6.2007 0:00;192.168.1.1;text in here", ";")oÝ÷ ÛMú½ªôríj)ì&j|©ç±ªÞ¶«{Mú½ªõ Edited June 11, 2007 by poisonkiller Link to comment Share on other sites More sharing options...
geezery Posted June 11, 2007 Author Share Posted June 11, 2007 (edited) Thanks for the tip, but I still can't populate my list. I think that there is something wrong with the For loop. Func _UpdateList() _GUICtrlListClear($TimeList) _GUICtrlListClear($IpList) _GUICtrlListClear($InfoList) Dim $ReadedFile _FileReadToArray("IPS.txt",$ReadedFile) For $i = $ReadedFile[1] to 0 step -1 $Splitted = StringSplit($ReadedFile[$i],";") _GUICtrlListAddItem($Timelist,$Splitted[0]) _GUICtrlListAddItem($IpList,$Splitted[1]) _GUICtrlListAddItem($InfoList,$Splitted[2]) Next EndFunc Edited June 11, 2007 by geezery Link to comment Share on other sites More sharing options...
SpookMeister Posted June 11, 2007 Share Posted June 11, 2007 Thanks for the tip, but I still can't populate my list. I think that there is something wrong with the For loop. Func _UpdateList() _GUICtrlListClear($TimeList) _GUICtrlListClear($IpList) _GUICtrlListClear($InfoList) Dim $ReadedFile _FileReadToArray("IPS.txt",$ReadedFile) For $i = $ReadedFile[1] to 0 step -1 $Splitted = StringSplit($ReadedFile[$i],";") _GUICtrlListAddItem($Timelist,$Splitted[0]) _GUICtrlListAddItem($IpList,$Splitted[1]) _GUICtrlListAddItem($InfoList,$Splitted[2]) Next EndFuncAs a guess, shouldnt that be For $i = $ReadedFile[0] to 0 step -1 [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
poisonkiller Posted June 11, 2007 Share Posted June 11, 2007 As a guess, shouldnt that be For $i = $ReadedFile[0] to 0 step -1I was thinking more like this: For $i = $ReadedFile[0] to 1 step -1 Link to comment Share on other sites More sharing options...
geezery Posted June 11, 2007 Author Share Posted June 11, 2007 (edited) I had it just like poisonkiller putted. But when I compile the script and execute it only flashes and closes. expandcollapse popup#include <GUIConstants.au3> #include <GuiList.au3> #include <GuiListView.au3> #include <file.au3> ; Change to OnEvent mode Opt("GUIOnEventMode", 1) ;Main Gui and it Controls $MainWindow = GUICreate("date", 1024, 768,50, 10, 0x04CF0000) $LabelIP = GUICtrlCreateLabel("IP-Address",205,20) $LabelInfo = GUICtrlCreateLabel("text",310,20) $TimeList=GUICtrlCreateList ("" , 100,34,100,700) $IpList=GUICtrlCreateList ("" , 200,34,100,700) $InfoList=GUICtrlCreateList ("" , 300,34,700,700) GUISetState(@SW_SHOW) ;Activate the Window Close Button GUISetOnEvent($GUI_EVENT_CLOSE, "_Terminate") ;Main Program ;Call Functions. While 1 ;Declare how often functions are reloaded _UpdateList() $RefreshDelay = 10000 sleep ($RefreshDelay) wend ;Functions Func _UpdateList() Dim $IpList, $InfoList, $TimeList _GUICtrlListClear($TimeList) _GUICtrlListClear($IpList) _GUICtrlListClear($InfoList) Dim $ReadedFile _FileReadToArray("IPS.txt",$ReadedFile) For $i = $ReadedFile[0] to 1 step -1 $Splitted = StringSplit($ReadedFile[$i],";") _GUICtrlListAddItem($TimeList,$Splitted[0]) _GUICtrlListAddItem($IpList,$Splitted[0]) _GUICtrlListAddItem($InfoList,$Splitted[1]) Next EndFunc ;Close Button Func _Terminate() $started = 0 Exit EndFunc Edited June 11, 2007 by geezery Link to comment Share on other sites More sharing options...
geezery Posted June 11, 2007 Author Share Posted June 11, 2007 What am I missing here? Link to comment Share on other sites More sharing options...
poisonkiller Posted June 11, 2007 Share Posted June 11, 2007 Try changing this line in _UpdateList() function: Dim $ReadedFile to this: Dim $ReadedFile[_FileCountLines("IPS.txt")+1] Link to comment Share on other sites More sharing options...
geezery Posted June 11, 2007 Author Share Posted June 11, 2007 Thanks it works, but I cant find any data on _GUICtrlListAddItem($InfoList,$Splitted[3]) Only [1] = 10.6.2007 0:00 [2] = 192.168.1.1 Where is the text cell? 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