# Call a Subroutine

**URL:** <https://forum.universal-robots.com/t/call-a-subroutine/2582>\
**Category:** URCaps SDK\
**Created:** [August 23, 2018, 11:29am UTC](https://forum.universal-robots.com/t/call-a-subroutine/2582 "2018-08-23T11:29:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon32366091](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@anon32366091](https://forum.universal-robots.com/u/anon32366091)\
**Post date:** [August 23, 2018, 11:29am UTC](https://forum.universal-robots.com/t/call-a-subroutine/2582/1 "2018-08-23T11:29:37Z")

</div>

Hello everyone,

I want to create a Call to a Subroutine with Java code.  
But I’m not sure or it is possible. Has somone done that before or nows if it is possible or not?

With regards,

Dvoortman

---

<div class="post-metadata">

**Author:** ![SonglinCai](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/songlincai/32/478_2.png) [@SonglinCai](https://forum.universal-robots.com/u/SonglinCai)\
**Post date:** [August 24, 2018, 1:32am UTC](https://forum.universal-robots.com/t/call-a-subroutine/2582/2 "2018-08-24T01:32:35Z")

</div>

What do you want to achieve by calling a subroutine? What does the subroutine do? Just sending the subroutine is feasible. If you try to get something back, it needs some workaround.

---

<div class="post-metadata">

**Author:** ![anon12495347](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@anon12495347](https://forum.universal-robots.com/u/anon12495347)\
**Post date:** [September 5, 2018, 11:28am UTC](https://forum.universal-robots.com/t/call-a-subroutine/2582/3 "2018-09-05T11:28:34Z")

</div>

We just like to write a script line ‘call subroutineA’ where subroutineA is an exisiting subroutine in the current program where the URCAP action is called. We like to use rather subroutines instead of generate a lot of script lines including whiles / sets / loops etc since this set of code is fixed

---

<div class="post-metadata">

**Author:** ![anon12495347](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@anon12495347](https://forum.universal-robots.com/u/anon12495347)\
**Post date:** [September 5, 2018, 3:44pm UTC](https://forum.universal-robots.com/t/call-a-subroutine/2582/4 "2018-09-05T15:44:51Z")

</div>

I found some workaround also now. Just create a function (via script beforehand in the (template) program or via scriptwriter) and via script writer add a line : "VarA=FunctionX()’. This will simple execute the functionX.
