Reading installation/global variables in java

Hey, is there any way to read variable values in java code? For example using some kind of daemon?
For example I have a variable “i_var_25” set up in Installation menu, and now i’d like to display the value for that variable in the UI. Is that possible?

According to @jbm in this post: Reading Installation Variable Values to URCap - #3 by chris.briedenhann

No. The value only exists to Polyscope when the program is running. You may be able to pull the value via the ScriptExporter when the program is actually running using the secondary interface, but I haven’t tried that for myself, so it might not work either.

1 Like

Okay, apparently there is a way to do this via an undocumented command in the dashboard server:

So to get this working, you would have to build a python daemon.

#!/usr/bin/env python

import socket
import time
import sys

import xmlrpclib
from SimpleXMLRPCServer import SimpleXMLRPCServer

def getVar(variableName):
	s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
	s.connect(('', 29999))
	cmd = 'getVariable ' + variableName
	cmd = cmd + '\n'
	rcvd = s.recv(4096)
	return rcvd

server = SimpleXMLRPCServer(("", 12345))
server.register_function(getVar, "getVar")

Then you’d have to put this daemon in the resources folder in your urcap directory, register the daemon service and then call this daemon out from the java code and it should work.

But haven’t tested it yet so can’t be 100% sure