Hi
Is it possible to call a LOCAL PROC using the FPSDK and callRoutine()? I can successfully call a globally declared PROC but not one declared local.
Hi
Is it possible to call a LOCAL PROC using the FPSDK and callRoutine()? I can successfully call a globally declared PROC but not one declared local.
So I got around this in a similar way to the runRoutineButton, in that I set a global string indicating the local function to run, i.e. “myModule:myRoutine” and then I call a global routine that just does a late binding routine call on that string.
This is obviously a horrible work around and I’m hoping that there is another option that doesn’t require any global routines and variables. I figure that as a routine belongs to a module, there must be some way of passing in the module so that a local routine can be called.
For anyone that is interested, here is the code I use:
C#:
//Create bindings
Controller controller = new Controller();
Task task = controller.Rapid.GetTask(“myTask”);
Module runRoutineModule = task.GetModule(“runRoutineModule”);
RapidData routineName = runRoutineModule.GetRapidData(“routineToCall”);
//Set string indicating routine to call
routineName.Value = new ABB.Robotics.Controllers.RapidDomain.String(“myModule:myRoutine”);
//Call global routine
myTask.CallRoutine(“runRapidRoutine”);
//Dispose bindings
routineName.Dispose();
runRoutineModule.Dispose();
task.Dispose();
controller.Dispose();
RAPID:
MODULE runRoutineModule(SYSMODULE)
PERS string routineToCall := “”;
PROC runRapidRoutine()
IF routineToCall <> “” THEN
%routineToCall%;
ELSE
TPWrite “Routine name must be set before call”;
RETURN;
ENDIF
routineToCall := “”;
ERROR
routineToCall := “”;
RETURN;
UNDO
routineToCall := “”;
ENDPROC
ENDMODULE