Arduino Forum

Using Arduino => Programming Questions => Topic started by: Chaos_Lord on Jun 01, 2012, 09:12 pm

Title: Call function from an array
Post by: Chaos_Lord on Jun 01, 2012, 09:12 pm
Hello everyone,

is it some how possible to call funktion from an array?

What i want to do is a Systemcheck depending on some events which happens. These events write data in an Array

char* syscheck[] = {"Timer" , "Sensor"};

syscheck now has the names of the funkctions which should be called.

Do i have to check every entry per hand and when it is in the array call the function "per hand" or can i somehow do a call direktly?

CL

PS my english is bad, so sorry for it   :~
Title: Re: Call function from an array
Post by: AWOL on Jun 01, 2012, 09:15 pm
Yes, you can have an array of function pointers, but these are not the same as strings.
Title: Re: Call function from an array
Post by: Arrch on Jun 01, 2012, 09:24 pm
Example of function pointer array:

http://stackoverflow.com/questions/252748/how-to-use-array-of-function-pointers (http://stackoverflow.com/questions/252748/how-to-use-array-of-function-pointers)
Title: Re: Call function from an array
Post by: Chaos_Lord on Jun 01, 2012, 09:57 pm
Thanks for the quick answers,

i tried to work as the exaple shows, but always get
Quote
invalid conversion from 'void (*)() to 'void*'


when i try compiling it with arduino
Title: Re: Call function from an array
Post by: Arrch on Jun 01, 2012, 10:18 pm

Thanks for the quick answers,

i tried to work as the exaple shows, but always get
Quote
invalid conversion from 'void (*)() to 'void*'


when i try compiling it with arduino


There were multiple examples, so without seeing the exact code you are using and what line that refers to, it's a bit difficult to say...