Jump to content

execute functions from array


xwvc
 Share

Recommended Posts

First of all, I'm just a beginner :D

I don't have a technical background, but I want to automate some stuff which will make my life a lot easier ;p

I've got following array (see attachement)

My problem is as follows: I want to execute the functions in column 2 in the order defined in column 1.

In this case, I want to execute func3 first,then func8, func2, etc.

If no value is set in column 1, the function should not be executed...

I know you can sort the first column with _ArraySort($myArray, 0, 0, 0, 0)

Then I guess I can get the value from row 0($myArray[0][1]) and execute this one, then get the content of [1][1],...

But then, how do I know on which row I have to stop executing the functions?

Do I have to write an if statement?

-> if [0][0] = "" then exit else "execute function on [0][1]" endif

-> if [1][0] = "" then exit else "execute function on [1][1]" endif

-> etc...

I guess there is an easier way, I just don't know how...

Can somebody help me, or at least give me a tip / hint / clue how I can get this done?

Thanks!

post-52982-12531984214485_thumb.jpg

Link to comment
Share on other sites

This is oversimplified, but may help you on your way:

#include <Array.au3>

Local $myArray[10][2] = [ _
["",  "func1"], _
[3,   "func2"], _
[1,   "func3"], _
[4,   "func4"], _
["",  "func5"], _
["",  "func6"], _
["",  "func7"], _
[2,   "func8"], _
["",  "func9"], _
[5,  " func10"]]

_ArrayDisplay($myArray, "BEFORE Sort")
_ArraySort($myArray,0,0,0,0)
_ArrayDisplay($myArray, "AFTER Sort")

For $i = 0 to 9
if $myArray[$i][0] <> "" Then
  MsgBox(0,"Function to run",$myArray[$i][1])
EndIf
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...