supadodger Posted March 23, 2009 Share Posted March 23, 2009 (edited) $days = StringSplit("Sun,Mon,Tue,Wed,Thu,Fri,Sat", ",") $main = 0 Do msgbox (0,"", $days) $main = $main + 1 Until $main = 7 msgbox is blank everytime. i do realize that im doing it wrong. i just dont know how to do what i want. Edited March 23, 2009 by supadodger Link to comment Share on other sites More sharing options...
Miniz Posted March 23, 2009 Share Posted March 23, 2009 (edited) #include <Array.au3> $days = _ArrayCreate("Sun","Mon","Tue","Wed","Thu","Fri", "Sat") $x = 0 While $days[$x] <> "" msgbox (0,"", $days[$x]) $x=$x+1 WEnd Or $days = StringSplit("Sun,Mon,Tue,Wed,Thu,Fri,Sat", ",") $main = 1 Do msgbox (0,"", $days[$main]) $main = $main + 1 Until $main = 8 Here u go ^^ Edited March 23, 2009 by Miniz Link to comment Share on other sites More sharing options...
supadodger Posted March 23, 2009 Author Share Posted March 23, 2009 i guess i didnt really say what i need. im trying to read a text file that goes : mon,tue,wed,thur,fri,sat,sun then my code will for example end up being $days = StringSplit("Sun,Mon,Tue,Wed,Thu,Fri,Sat", ",") so i want to somehow everytime choose one of the delimited options. it could go in order or randomly select them i dont really care. Link to comment Share on other sites More sharing options...
Developers Jos Posted March 23, 2009 Developers Share Posted March 23, 2009 $days is an array. Look at the Helpfile for the stringsplit() example. SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
supadodger Posted March 23, 2009 Author Share Posted March 23, 2009 #include <Array.au3> $days = _ArrayCreate("Sun","Mon","Tue","Wed","Thu","Fri", "Sat") $x = 0 While $days[$x] <> "" msgbox (0,"", $days[$x]) $x=$x+1 WEnd thanks for the code. and i know your probly a busy man but can you explain to me exactly what you did there? i want to be able to do for myself instead of always coming back asking questions. i can brute force most things i want to do and my code sure is ugly but mostly if i can get it working i do it myself. Link to comment Share on other sites More sharing options...
Mat Posted March 23, 2009 Share Posted March 23, 2009 not sure what you want to do but your problem is $days is an array, so $days means nothing $days = StringSplit("Sun, Mon, Tue, Wed, Thu, Fri, Sat", ",") $main = 0 Do msgbox (0,"", $days[$main]) $main = $main + 1 Until $main = 7 MDiesel AutoIt Project Listing Link to comment Share on other sites More sharing options...
Miniz Posted March 23, 2009 Share Posted March 23, 2009 (edited) As sead above $Days is an array, and when you read from an array you nead to make " [number] " of the value you want to read read from after $days. Like this $days[0], $days[0] will return Sun. But when you use stringsplit the first value will be the number of times it splitted the text. Edited March 23, 2009 by Miniz Link to comment Share on other sites More sharing options...
Mat Posted March 23, 2009 Share Posted March 23, 2009 As sead above $Days is an array, and when you read from an array you nead to make " [number] " of the value you want to read read from after $days. Like this $days[0], $days[0] will return Sun. $days[0] will return the number of arrays... but yes that is what I was doing with main and is correct. as previosly mentioned by jos, read the helpfile under arrays and string split. AutoIt Project Listing Link to comment Share on other sites More sharing options...
Richard Robertson Posted March 23, 2009 Share Posted March 23, 2009 The 0 subscript is not required to return the count of the array. Link to comment Share on other sites More sharing options...
Mat Posted March 23, 2009 Share Posted March 23, 2009 in the context of the script used (no flag) it does. AutoIt Project Listing Link to comment Share on other sites More sharing options...
erik7426 Posted March 23, 2009 Share Posted March 23, 2009 You found StringSplit but then apparently didn't read the help file on it. There is also a cleaner way to parse through the days... $days = StringSplit("Sun,Mon,Tue,Wed,Thu,Fri,Sat", ",") For $main = 1 to $days[0] MsgBox(0,"", $days[$main]) Next $days = StringSplit("Sun,Mon,Tue,Wed,Thu,Fri,Sat", ",") $main = 0 Do msgbox (0,"", $days) $main = $main + 1 Until $main = 7 msgbox is blank everytime. i do realize that im doing it wrong. i just dont know how to do what i want. 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