Jump to content

delimiter help plz.


Recommended Posts

$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
Link to comment
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

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
Link to comment
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.

Link to comment
Share on other sites

  • Developers

$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

#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

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
Link to comment
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.

Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...