Update values every time MyDaemon URCap is called

Greetings,

I have (hopefully) an easy question I need help with. I’m testing “My Deamon” URCaps, and I have managed to modify the hello-world.py in a way that it saves data in a text file. Right now it only saves the name typed in the “My Deamon” URCap. Now that it saves data (typed name) periodically to the text file, I’m planning to implement some Variable values as well.

I just can’t figure out where I need update the values so the string send to the deamon is updated every robot program cycle. Below is my generateScript(), and with it I can send values from the integer CustomValue00, but it seems “CustomValue00++;” is run only once when I start the robot program. Stopping and restarting the robot program increases the value of CustomValue00, so I can only see the “CustomValue++” is run when the program runs the first loop. Is it so that generateScript() is run only once and then the script generated by it is repeated every time that URCap is called from the robot program? And if so, what is the correct place to update any values every time the URCap is called?

A simple example that would help me a lot would be code for a program that popups a message and every time the value in the message would increase.

Thank you in advance for any tips!

@Override
public void generateScript(ScriptWriter writer) {
	
	CustomValue00++;
	writer.assign("mydaemon_message", getInstallation().getXMLRPCVariable() + ".get_message(\"" + getName() + CustomValue00 + "\")");
	writer.assign("mydaemon_title", getInstallation().getXMLRPCVariable() + ".get_title()");
	
	writer.writeChildren();
}

Now that I think about it, it would be better to not use any variable which gets it’s value on the URCap side, but rather a Variable on the robot side (which is defined in the Installation tab or the script creates it). This way the value could be increased every time on the robot side. Any tips how to approach this?

Update:
I can use for example “get_actual_tcp_pose()” to get z-axis value. That value can now be seen from a popup or it is written in the text file by the hello-world.py. But the value is always the same even if robot has moved. It always shows the z value where the robot was when the play button was first pressed.