Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

The Function always take the last return

I create a Function for the setuptime. In the delay time in my service Block i write: f_getDuration(agent, v_Predecessor)
v_Predecessor is my variable typ agent and i write this in on exit: v_Predecessor = agent;

But the if function are not working. The service Block does only take the last return 10. why does it not accept my function?
Oberteil, Unterteil, Ring and Halteteil are my Agents.
CurrentAgent and predecessor are Arguments Type Agent
This is my function:

if (currentAgent == Oberteil && predecessor == Unterteil) {
    return 45;
} else if (currentAgent == Oberteil && predecessor == Halteteil) {
    return 40;
}else if (currentAgent == Oberteil && predecessor == Ring) {
    return 45;
}else if (currentAgent == Unterteil && predecessor == Oberteil) {
    return 45;
}else if (currentAgent == Unterteil && predecessor == Halteteil) {
    return 40;
}else if (currentAgent == Unterteil && predecessor == Ring) {
    return 45;
}else if (currentAgent == Halteteil && predecessor == Oberteil) {
    return 40;
}else if (currentAgent == Halteteil && predecessor == Unterteil) {
    return 40;
}else if (currentAgent == Halteteil && predecessor == Ring) {
    return 45;
}else if (currentAgent == Ring && predecessor == Oberteil) {
    return 45;
}else if (currentAgent == Ring && predecessor == Unterteil) {
    return 45;
}else if (currentAgent == Ring && predecessor == Halteteil) {
    return 45;
}
return 10; 

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Right now, the function will always return 10 because this is not part of the "if-else" block (it overwrites the return values). If you only want to return "10" if the other conditions do not hold, put an "else" before "return 10;"

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading