Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Conditional call to a program from custom code instruction

#1
Is it possible to have a condition to call/run a program from a "custom code" instruction?

Now I have to split the code to insert the program call. Not very convenient for me.

Example of custom code:
Code:
IF CNC1_CloseDoor == 1
CALL CloseDoor //not working
CNC1_DoorClosed = 1
CNC1_DoorOpened = 0
END
#2
Yes, you can enable flow control in RoboDK by following these steps:
  1. Right click on the station
  2. Select Station Parameters
  3. Check the option Enable flow control statements

This will allow you to simulate IF and WHILE statements when using code insert instructions. Also, if you have assignments they will be calculated and you'll see them in the station parameters. These are settings stored with the RDK station.

I attached a sample project that shows a proof of concept of your example.
   


Attached Files
.rdk   FlowControlTest.rdk (Size: 1.42 KB / Downloads: 100)
#3
Hi, Albert! I don't think I explained it well. I meant the ability to call the program from code insert instruction. Otherwise you have to divide the code into several lines, which is not very convenient for debugging. But I have already realized that it is better to use robodk API for this task.


Attached Files Image(s)
   
#4
Thank you for your feedback.

To better clarify: the Insert code instruction can simulate flow control statements but it will not execute program calls. You should better use the example I shared instead, if you want to use the user interface.
  




Users browsing this thread:
1 Guest(s)