Determining if there is an argument present in TP

  • Say I call a program as follows:


    Code
    CALL SUBCALL(1) ;


    and inside of SUBCALL I have:


    Code
    IF AR[1]=1, JMP LBL[100] ;
    !Do stuff...
    END ;
    LBL[100] ;
    !Do other stuff...
    END ;


    It will run fine.


    But if I call the SUBCALL program without any arguments, like so:


    Code
    CALL SUBTEST ;


    It will fault on the if statement with an INTP-288 error. (Parameter does not exist)


    Code
    IF AR[1]=1, JMP LBL[100] ; <--INTP-288 FAULT
    !Do stuff...
    END ;
    LBL[100] ;
    !Do other stuff...
    END ;


    I want to know if there is anyway to test for the existence of an argument passed to the SUBCALL program.

    Check out the Fanuc position converter I wrote here! Now open source!

    Check out my example Fanuc Ethernet/IP Explicit Messaging program here!

  • As far as I know there is not a way to check for the existence of a parameter in a TP program.
    But you can do it using Karel.
    You can use this instruction ( Syntax : GET_TPE_PRM(param_no, data_type, int_value, real_value, str_value, status)
    To determine if the parameter exist and paste the result on a flag or register and check for that on your TP program.
    You need to have the Karel option loaded in your controller in order to be download any Karel program.
    Also you need to have the olpc-pro to compile the file on you pc.
    I would like to know if there is another way more simple.

  • Unfortunately, the job I am working on, the customer did not buy any options whatsoever. So no karel for me. Also, you no longer get a free pass on karel for the R30-iB.


    Its starting to sound like that there isn't a way to do it. I really wish I could do something like this:


    Code
    IF AR[1]<>EXIST, JMP LBL[10] ;
    IF AR[1]=1, JMP LBL[100] ;
    LBL[10] ;
    !Do default stuff...
    END ;
    LBL[100] ;
    !Do other special stuff...
    END ;

    Check out the Fanuc position converter I wrote here! Now open source!

    Check out my example Fanuc Ethernet/IP Explicit Messaging program here!

  • Still not sure I understand what your wanting to do. where you have CALL SUBTEST you need to have a variable for the argument, CALL SUBTEST(1), thats why you are getting that alarm.

  • Well, if Karel is not an option,
    Then you will need to have that argument in all your calls. Probably use a negative value when the argument shouldn't exist.


    IF AR[1]<>-1, JMP LBL[10] ;
    IF AR[1]=1, JMP LBL[100] ;
    LBL[10] ;
    !Do default stuff...
    END ;
    LBL[100] ;
    !Do other special stuff...
    END ;


    Yeap! I can't think on something different. I know... It is too bad and I guess Fanuc guys believe that programmers don't need that option using TP programs... As I said in Karel it is possible.



  • I was thinking of something like this too.

  • I decided to go with a register as the solution.


    The call:

    Code
    89:  !Advance the slide for gripper 1 ;
      90:  !and ignore switch. ;
      91:  R[192:Enb Quick Exit]=1    ;
      92:  CALL G1ADVANCE    ;


    How I use it:


    Maybe sometime in the future we will get this functionality. Seeing as how it took until about 2007 for Fanuc to implement program names longer than 8 characters, I bet we should have something like what I want around 2025 or so.

    Check out the Fanuc position converter I wrote here! Now open source!

    Check out my example Fanuc Ethernet/IP Explicit Messaging program here!

  • Maybe sometime in the future we will get this functionality. Seeing as how it took until about 2007 for Fanuc to implement program names longer than 8 characters, I bet we should have something like what I want around 2025 or so.

    Darn, I guess I'm still 4 years too early looking for this same functionality...

Advertising from our partners