RobotStudio event

Find Module containing Proc

Hello,

Is it possible in RAPID to check if a certain PROC is defined and if so get the name of the module in which it is defined?

We are loading a module from a file using the Load instruction ("Load Test1.mod").
But in some cases it is possible that a module is still loaded ("Test2.mod") which contains a PROC with a name also defined in the module we are trying to load.

Here the (pseudo) code:

procName = "TestProc";
! Check module with PROC exists and delete if so
If <CheckHere> THEN
     EraseModule "<NameOfModule>";
ENDIF

! Load module and run the PROC
Load "Test1.mod"
%procName%;

We hoped to achieve it with the SetDataSearch i.c.w. the GetNextSym but were not able to find a PROC by name let alone finding the module it is defined.

We hope something like this is possible in RAPID  :).

Comments

  • lemster68
    lemster68 ✭✭✭
    Can you make those offending routines local to their respective modules and still retain the desired functionality?
    Lee Justice
  • Micky
    Micky ✭✭✭
    Unfortunately, there is no function in RAPID to determine if a routine already exists. You can only check if a module exists.

    As already suggested by lemester68, you could declare the routines locally, so that several routines with the same name can exist in the robot system without causing error messages.

    The call of the routine via late binding looks like this:
    %"ModuleName:RoutineName"%;
    The module name and the routine name are separated by a colon.

  • You can try to use the ERRNO to check that.

    Like this example maybe:

        ! You need that when the routine is local declared in other module
        %"ModuleName:RoutineName%;
        ! You can use this when the routine is gloable declared
        %"RoutineName%;
        ! example
        %"mp"+nActPos+"_p"+nTarget%;
         
      ERROR
        IF ERRNO=ERR_CALLPROC OR ERRNO=ERR_REFUNKPRC THEN
          ! here you can made the error handling with RAISE or RETRY or other logic.
        ENDIF
        RETURN;
      ENDPROC

    Maybe is helpfully.

    Take care.