# Type error on popup containing custom function

**URL:** <https://forum.universal-robots.com/t/type-error-on-popup-containing-custom-function/22660>\
**Category:** Java\
**Created:** [July 14, 2022, 11:04am UTC](https://forum.universal-robots.com/t/type-error-on-popup-containing-custom-function/22660 "2022-07-14T11:04:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon30216221](https://avatars.discourse-cdn.com/v4/letter/a/f17d59/32.png) [@anon30216221](https://forum.universal-robots.com/u/anon30216221)\
**Post date:** [July 14, 2022, 11:04am UTC](https://forum.universal-robots.com/t/type-error-on-popup-containing-custom-function/22660/1 "2022-07-14T11:04:36Z")

</div>

Hi all,

I have implemented a custom function based on a previous question I asked here on the forum: [Link to question](https://forum.universal-robots.com/t/assign-program-node-return-value-to-assignment-variable/22524)

I chose the implementation where I add a function. This worked fine until I tried to test it out.

This is the code in my InstallationNodeContribution generateScript method:

```auto
        writer.appendLine("def readpmc(address, dataType, dataNumber):");
		writer.appendLine("\t cnc.rdpmc(address, dataType, dataNumber)");
		writer.appendLine("end");
		
		try {
			System.out.println("Generating function!");
			FunctionModel functionModel = apiProvider.getInstallationAPI().getFunctionModel();
			functionModel.addFunction("readpmc", "address", "dataType", "dataNumber");
		}catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}

```

This is the error I’m getting:

```auto
Type error: left-hand side of the expression expected type ''int / float/ bool / string 
/ pose' but found 'None'

Script code
global var_1 = cnc.rdpmc(5,0,800)
$ 4 "var_2=readpmc(5,0,800)"
global var_2= readpmc (5, 0, 800)
$ 5 "Popup"
popup(str_cat("", var_2), "Message", False, False blocking=True <--- line that causes error

```

My guess is that it is caused because there is no return value from my readpmc to display in the popup? Can someone tell me if this is the case?

---

<div class="post-metadata">

**Author:** ![eric.feldmann](https://avatars.discourse-cdn.com/v4/letter/e/94ad74/32.png) [@eric.feldmann](https://forum.universal-robots.com/u/eric.feldmann)\
**Post date:** [July 14, 2022, 12:21pm UTC](https://forum.universal-robots.com/t/type-error-on-popup-containing-custom-function/22660/2 "2022-07-14T12:21:25Z")

</div>

Yep I would say that’s what the issue is. Your readpmc() function calls cnc.rdpmc() and then quits. It needs to return the output of that function call, whatever it is
