Beware that setting variables does not work with "Run Keyword If". It works in "IF" but if you are using an older version of Robot then use "Set Variable If" instead (https://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Set%20Variable%20If):
${var1}= Set Variable If ${rc} == 0 val1 val2