Jump to content

Recommended Posts

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
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
Posted

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.

Posted

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

Posted

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

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
Posted

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.

Posted

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.

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
×
×
  • Create New...