RobotStudio event

Test if PROC is defined

I have a case where I would like to execute a PROC if it is defined.

My case is that I upload a RAPID program, and if the program has a special PROC defined, then I would like to execute it...

Basically in pseudocode
IF (defined(nn)=true) THEN
 EXEC nn;
ENDIF

Is this possible in RAPID?


Comments

  • Hello,
     

    Yes, you should be able to do this.  One suggestion is by first searching for the Proc symbol (see SetDataSeach and GetNextSym instructions) to find the Proc name, and then use "late binding" to execute the proceedure (put the Proc Name into a string and then call the string as a proc with %stringname%)

     

    You could also skip the symbol searching and simply call the procedure using late binding, if the procedure exists, it will be called, otherwise an error will occur and you can handle the error automatically in the error handler of the procedure.

     

       Steve

     
  • Ok, thanks for the suggestions - I will try it out soon.

    Too bad there is not "PROC_isDeFined(String_ProcName)" method hidden somewhere Smile


  • Hello,
     
    Yes, you should be able to do this.  One suggestion is by first searching for the Proc symbol (see SetDataSeach and GetNextSym instructions) to find the Proc name,
    I'm trying to do exactly this, but I can't figure out how to do it.
    How can you search PROC names with SetDataSearch?

    For example if i'm trying to find all PROCs that begin with a word Process. What should I use as SetDataSearch Type argument?

        SetDataSearch "??????"\Object:="Process*";
        WHILE GetNextSym(name,block \Recursive) DO
            TPWrite("found: " + name);
        ENDWHILE