-1

Below is my script :

increment
    ${delCount}=    Set Variable    0
    :FOR    ${loopIndex}    INRANGE    0    8
    \    Log    ${loopIndex}
    \    ${delCount}=    Run Keyword If    '${loopIndex}'=='${3}'    Run Keywords    ${delCount+3}
    \    ...    ELSE IF    '${loopIndex}'=='${6}'    Run Keywords    ${delCount+6}
    \    ...    ELSE    Sleep    1s
    Log    ${delCount}

All I need to do is to increment the variable when the condition satisfies. How to go about this? I tried below :

Run Keywords Evaluate ${delCount}+${3}

Run Keywords ${delCount}= Set Variable ${delCount}+${3}

Run Keyword Evaluate ${delCount}

Prasath Govind
  • 720
  • 2
  • 10
  • 30

2 Answers2

1

Like this:

${delCount}=    Set Variable    0
:FOR    ${loopIndex}    IN RANGE    0    8
\    Log    ${loopIndex}
\    ${delCount}=    Run Keyword If    ${loopIndex} == 3    Evaluate    ${loopIndex} + ${delCount}
\    ...    ELSE IF    ${loopIndex} == 6    Evaluate    ${delCount} + 6
\    ...    ELSE    Sleep    1s
Log    ${delCount}
ILostMySpoon
  • 2,399
  • 2
  • 19
  • 25
  • When `loopIndex` is not 3 or 6, `delCount` will be set to `None` - because that's the return value of `Sleep 1s`. So in the final ELSE substitute that with `Set Variable ${delCount}` - and that will preserve its current value. Thus one more condition will be needed for the Sleep - `\ Run Keyword If ${loopIndex} not in (3, 6) Sleep 1s`, and it should be good. – Todor Minakov Jun 29 '17 at 19:34
0
${delCount} | Set Variable If | ${loopIndex} == 3 | ${delCount} + ${loopIndex} | ${delCount}

${delCount} | Set Variable If | ${loopIndex} == 6 | ${delCount} + 6 | ${delCount}
4b0
  • 21,981
  • 30
  • 95
  • 142