# Passing unlimited number of arguments in ProcCall

**URL:** <https://tech-community.robotics.abb.com/t/passing-unlimited-number-of-arguments-in-proccall/10149>\
**Category:** RAPID Programming\
**Tags:** rapid, rapid-code, abb, procedure-call\
**Created:** [April 26, 2021, 9:15pm UTC](https://tech-community.robotics.abb.com/t/passing-unlimited-number-of-arguments-in-proccall/10149 "2021-04-26T21:15:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JohnG](https://avatars.discourse-cdn.com/v4/letter/j/f4b2a3/32.png) [@JohnG](https://tech-community.robotics.abb.com/u/JohnG)\
**Post date:** [April 26, 2021, 9:15pm UTC](https://tech-community.robotics.abb.com/t/passing-unlimited-number-of-arguments-in-proccall/10149/1 "2021-04-26T21:15:26Z")

</div>

This question isn’t a show stopper for me at all. I have what I’m looking to do coded in a different way right now, just could be a lot cleaner if what I’m looking to do is possible. Is there a way to create a procedure without a predefined set of arguments?

such as in Python:

def ProcToCall (\*\*args):  
pass

One workaround I know I can do is predefine a larger list of optional arguments like below, but wouldn’t be ideal for what I’m trying to achieve.

PROC ProcToCall (\VAR num Arg1, \VAR num Arg2…)  
IF Present(Arg1) THEN  
!Do something  
ENDIF  
IF Present(Arg2) THEN  
!Do something  
ENDIF  
…

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Micky](https://avatars.discourse-cdn.com/v4/letter/m/a5b964/32.png) [@Micky](https://tech-community.robotics.abb.com/u/Micky)\
**Post date:** [April 27, 2021, 8:12am UTC](https://tech-community.robotics.abb.com/t/passing-unlimited-number-of-arguments-in-proccall/10149/2 "2021-04-27T08:12:43Z")

</div>

Hello,  
you could pass an array that contains your required parameters.

If you define the array directly in the routine call, you can pass as many parameters as you want without having to create an array as a variable previously.

Attached is an example:

```auto
PROC TEST1()
    ProcToCall;
    ProcToCall\Args:=[1];
    ProcToCall\Args:=[1,2,4];
  ENDPROC

  PROC ProcToCall(\num Args{*})
    VAR num nDim;
       !Get the number of parameters
    IF Present(Args) THEN
      nDim:=Dim(Args,1);
      IF Present(Args) AND nDim>=1 THEN
        TPWrite "Arg1: "\num:=Args{1};
      ENDIF
      IF Present(Args) AND nDim>=2 THEN
        TPWrite "Arg2: "\num:=Args{2};
      ENDIF
    ENDIF
  ENDPROC

```

---

<div class="post-metadata">

**Author:** ![JohnG](https://avatars.discourse-cdn.com/v4/letter/j/f4b2a3/32.png) [@JohnG](https://tech-community.robotics.abb.com/u/JohnG)\
**Post date:** [April 27, 2021, 4:03pm UTC](https://tech-community.robotics.abb.com/t/passing-unlimited-number-of-arguments-in-proccall/10149/3 "2021-04-27T16:03:38Z")

</div>

This is exactly what I was looking for. Thanks!
