# When to call own Functions

**URL:** <https://forum.universal-robots.com/t/when-to-call-own-functions/12310>\
**Category:** URCap Development\
**Created:** [February 12, 2021, 9:31am UTC](https://forum.universal-robots.com/t/when-to-call-own-functions/12310 "2021-02-12T09:31:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon97608879](https://avatars.discourse-cdn.com/v4/letter/a/439d5e/32.png) [@anon97608879](https://forum.universal-robots.com/u/anon97608879)\
**Post date:** [February 12, 2021, 9:31am UTC](https://forum.universal-robots.com/t/when-to-call-own-functions/12310/1 "2021-02-12T09:31:45Z")

</div>

For my Bachelor Project I am coding Costum Popups for my Company. They work (The Popups show up), but the Problem I have is, that the Popups are not generated when the ProgrammNode is called. When i start the Programm, the Popup is generated and not when the ProgramNode is called.

Right now i am calling my generatePopup() Function inside the generateScript() Method.

A little bit of Info, i am using a JPanel for the Popup and the user can set properties like the color, size etc.in the Programmnode.  
The user sets the Properties while the code isnt Running in a normal ProgramNodeView.  
My question now is, how do I achieve that my“Popup” generates when the ProgramNode is called and not when the whole Program is started?

Thank you!

---

<div class="post-metadata">

**Author:** ![Ebbe](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/ebbe/32/1413_2.png) [@Ebbe](https://forum.universal-robots.com/u/Ebbe)\
**Post date:** [February 12, 2021, 2:39pm UTC](https://forum.universal-robots.com/t/when-to-call-own-functions/12310/2 "2021-02-12T14:39:56Z")

</div>

Hi @anon97608879,

The purpose for the Java method generateScript(), is to contribute to the construction of the URScript the URController is going to execute. You can find more info on the topic here:  
[https://plus.universal-robots.com/urcap-basics/ur-software-architecture/](https://plus.universal-robots.com/urcap-basics/ur-software-architecture/)  
The simple solution is that your Program in the scriptWriter add a line where you call the script function _popup(s, title=’Popup’, warning=False, error=False, blocking=False)_  
the string _s_ can contain a limited subset of html to format the popup.

If you want to construct a Swing popup then you task will be to have a server running on the Java side and the script generated shall then send a message(plain socket or XML rpc) to inform the Java side that it is time to display the popup.

I hope it gives you a clue for the direction!

---

<div class="post-metadata">

**Author:** ![anon97608879](https://avatars.discourse-cdn.com/v4/letter/a/439d5e/32.png) [@anon97608879](https://forum.universal-robots.com/u/anon97608879)\
**Post date:** [February 13, 2021, 11:06am UTC](https://forum.universal-robots.com/t/when-to-call-own-functions/12310/3 "2021-02-13T11:06:10Z")

</div>

Thanks! I have constructed the Swing Popups already, just needed to know how to properly call them. I Will try to do that with a simple Socket Server!

---

<div class="post-metadata">

**Author:** ![sam.verity-hilton](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/sam.verity-hilton/32/6046_2.png) [@sam.verity-hilton](https://forum.universal-robots.com/u/sam.verity-hilton)\
**Post date:** [February 17, 2021, 2:53pm UTC](https://forum.universal-robots.com/t/when-to-call-own-functions/12310/4 "2021-02-17T14:53:13Z")

</div>

In the past I’ve used an XMLRPC server to allow URScript to call java functions, with the java side XMLRPC server implementation inspired by the following sample:

> [@URCap Sample: URCap with XML-RPC Server by Java (Dialog Script URCap)](https://forum.universal-robots.com/t/urcap-sample-urcap-with-xml-rpc-server-by-java-dialog-script-urcap/8707):
>
> NAME OF URCAP Dialog Script URCap with using XML-RPC (second version) Description of functionality: I uploaded the urcap which shows custom dialog by using socket commucation in the other day. In this time, the feature showing the dialog is implemented by XML-RPC daemon. Why is it used JAVA for XMLRPC daemon? It is possible to implement the keyboardInput feature of installation conribution on XMLRPC. GITHUB LINK Requirements: URCaps SDK v.1.9.0

I have then opened a connection to that server in URScript and used that to call java methods in real time when required.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/system/32/1_2.png) [@system](https://forum.universal-robots.com/u/system)\
**Post date:** [March 2, 2021, 12:07pm UTC](https://forum.universal-robots.com/t/when-to-call-own-functions/12310/5 "2021-03-02T12:07:54Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
