Sign in to follow this  
Followers 0
supadodger

delimiter help plz.

11 posts in this topic

#1 ·  Posted (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 by supadodger

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by Miniz

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#7 ·  Posted (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 by Miniz

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

The 0 subscript is not required to return the count of the array.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0