RobotStudio event

replace name with num value

Hi,

I have a slight problem, i have a randomGenerator witch gives me a number between 0 and 200. And i have 200 routines named "routine1, routine2" etc. And i want to do the rutin by random from the number i get from the randomGen. So to my question:

How do i replace the number 1 in routne1 with the value i get from my randomGen?

BR 

Comments

  • you could make a routine that accepts your number and use test / case to run each of your individual routines.. 

    TEST RandonNum
    CASE 1 :
    Routine1;
    CASE 2:
    Routine2;
    ENDTEST

    little bit tedious.. but without know what your doing with the 200 routines i cant think of much better.


  • Hello,
    You can use something called late binding to do this in a much simpler way. Please see the following example code:

     

    randomNumber :=GetRandomNumber;

    routineName := "Routine" + NumToStr(randomNumber, 0);

    %routineName%;

     

    This will call the routine with the name "Routine1" (if randomNumber is 1). 

     

    Good luck!

     

    BR frpa 
  • Hi
    You can use

    CallByVar - Call a procedure by a variable

    Example

    reg1 := 2;

    CallByVar "proc", reg1;

    Regards
    Knud Erik Lindberg
    Jorgensen Engineering