How to use a string type variable in KRC4

  • first of all there is no real string in KRL, but character array serves as substitute but this comes at a price... manipulation is rather cumbersome.


    next you did not define what you mean by "calling program".


    if you are thinking of calling program in a same interpreter by using name stored in a string, you would be out of luck ... unless you can sufficiently constrain the problem to a specific name format and/or predefined set of names.... in this case you can parse format and use SWITCH statement.


    if you are thinking of selecting and running program from another interpreter.... that can work... even if name is completely unexpected (for example something received through network or somehow entered by user). check key manuals listed in READ FIRST topic.

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • Thank you for your help.


    I want to create some programs with predefined names. examples: product1, product2.


    Where product 1 would use program 1 and product 2 would use program2.

    I understand that if I use swicth, I will have to enter an INT value, but in fact I would like to call the program by the name of the product.


    Then, I would replace the name of product 1 and product 2 with the customer's internal code. So I can call the program using the client's internal code.

  • sounds good... evaluate string using format to recognize it is starting with "PROGRAM" and extract value that follows as an integer

    then you can use Switch case...

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

Advertising from our partners