Jump to content

loop for that runs a function


Recommended Posts

hello,

i have data coming into my script that is dynamic

<x#xx>

let say $item holds that string, (string example - <5#23><2#24><5#25>)

how can i create a loop that will run the function done($qty,$id) for each set of <> that is in the string?

Link to comment
Share on other sites

can you explain that a little bit more please

i found this in the help file under for but i don't get it

For $i = 5 to 1 Step -1

MsgBox(0, "Count down!", $i)

Next

i found StringRegExp, that looks like something i should use, how do i use it?

Edited by seesoe
Link to comment
Share on other sites

$list_1 = "<2#4>,<4#5>"

$list_2 = StringSplit($list_1,",")

$list_3 = StringTrimLeft($list_2[1],1)

$list = StringTrimRight($list_3,1)

$item = StringSplit($list,"#")

done($item[1],$item[2])

but this of course will only do the first set of <>

how can i make the FOR do it for how ever much sets of <> there are?

Link to comment
Share on other sites

gaz was telling you to use a for loop. Like this:

$list_1 = "<2#4>,<4#5>,<1#5>,<2#5>"

$list_2 = StringSplit($list_1,",")
For $i=1 To $list_2[0]
$list_3 = StringTrimLeft($list_2[$i],1)
$list = StringTrimRight($list_3,1)
$item = StringSplit($list,"#")
done($item[1],$item[2])
Next
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...