RobotStudio event

Rapid code is not working.

Trying to add value to the variable - 'number', and if 'number' == 5 then do message box. Not working. My variable remains in 0.
My PROC:
PROC user_selection()
        VAR num answer;
        VAR num number;
        
        VAR btnres answer2;
        
         !Testing TPReadFK and IF, IFELSE statements.
         !PulseDO\PLength:=1.5, doFeedBkwd_W1_R1;
        
         !can be up to 5 uptions. If less then 5 write - stEmpty
        TPReadFK answer,"Select which way to go","Left","Right","Center","CheckLoop","Dispose Mudule";
        
        IF answer=1 THEN
            Pth_2_left;
            number := number + 1;
        ELSEIF answer=2 THEN
            Pth_3_right;
            number := number + 1;
        ELSEIF answer=4 THEN
            t_LogicLoopStop;
            number := number + 1;
        ELSEIF answer=5 THEN
            disposeModule;
            number := number + 1;
        ELSE
            Pth_1_center;
            number := number + 1;
        ENDIF
        
        IF number = 5 THEN
            UIMsgBox\Header:="UIMsgBox Header","Number is 5"\MsgLine2:=""\MsgLine3:=""\MsgLine4:=""\MsgLine5:=" "\Buttons:=btnOKCancel\Icon:=iconInfo\Result:=answer2;
        IF answer = resOK disposeModule;
        ENDIF
        !
    ENDPROC 

What I'm doing wrong?

Best Answer

  • EugeneB
    EugeneB
    Answer ✓
    I move my variable outside of my proc and it worked. Thanks.

Answers

  • soup
    soup ✭✭✭
    edited June 2018
    Do you get an error message?
  • soup
    soup ✭✭✭
    Try putting:

    TPWrite NumToStr(number, 0);
    Stop;

    at different places to see what the value is before and after you do number+1.

    Also, then put the VAR as a Global variable by putting it at the top of the module, outside a proc, and see if that changes the way it counts.

  • Nothing. Variable = 0;
    No error messages.