Loop through Functions

Hi,
I was wondering if there is a way of having a while loop or for loop that cycles though functions if the return is = to a set result.

for example:

void myFunction(){
// loop code goes here
 Test1();
 Test2();
 ........
 Test30();

 if any of the above return False then stop and goto returnFalse()
}

int Test1(){
}
.........
int Test30(){
}

trying to keep code to minimal as i have a significant amount of variable tests

mford29:
trying to keep code to minimal as i have a significant amount of variable tests

Same test repeatedly, separated in time? Different test each time with differing sensors? What exactly is being tested?

Why are the Test*() functions returning "int" not "bool"? What is "returnFalse()"?

consider

void func1 (void) { Serial.println (__func__); }
void func2 (void) { Serial.println (__func__); }
void func3 (void) { Serial.println (__func__); }
void func4 (void) { Serial.println (__func__); }
void func5 (void) { Serial.println (__func__); }

typedef void(*Func_t)(void);

Func_t funcs [] = {
    func1,
    func2,
    func3,
    func4,
    func5,
};

#define N_FUNC  (sizeof(funcs)/sizeof(Func_t))

// -----------------------------------------------------------------------------
void
setup (void)
{
    Serial.begin (9600);

    Func_t *f = funcs; 
    for (unsigned n = 0; n < N_FUNC; n++)
        (*f++)();
}

void
loop (void)
{
}

I can’t see why you’d want to obfuscate it so.

    for (unsigned n = 0; n < N_FUNC; n++)
        funcs[n]();
}

Thanks for the replies,

Each Test is slightly different, hence in separate functions. They will be returning "PASS" or "FAIL" strings. returnFalse() is a function that will stop the loop and display where it failed.

I'm looking for a simplified part of code rather than listing all the functions with if statements after each to check the return string

TheMemberFormerlyKnownAsAWOL:
I can’t see why you’d want to obfuscate it so.

    for (unsigned n = 0; n < N_FUNC; n++)

funcsn;
}

yes, that works as well (think you still need a “*”)

gcjr:
yes, that works as well (think you still need a “*”)

No