User Tools

Site Tools


accesssystempropertiesinscript

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
accesssystempropertiesinscript [2023/01/14 16:46] wikiadminaccesssystempropertiesinscript [2026/01/25 14:48] (current) wikiadmin
Line 1: Line 1:
 =====Access and Use System Properties (-D defined properties) in a Script===== =====Access and Use System Properties (-D defined properties) in a Script=====
 +
 +<note>This article also applies to accessing and using parameters set in ErgoTechConfiguration.properties</note>
  
 This article shows you how to get the values of system properties which are defined on the command line using -Dpropertyname=value. There are other ways to set system parameters for MIX or TransSECS applications, and the code examples shown below will also work for these methods. In MIX you can add a parameter to the the mix.properties file, and for TransSECS deployments (and also for MIX applications running TransSECS code) you can add a parameter to ErgoTechConfiguration.properties. This article shows you how to get the values of system properties which are defined on the command line using -Dpropertyname=value. There are other ways to set system parameters for MIX or TransSECS applications, and the code examples shown below will also work for these methods. In MIX you can add a parameter to the the mix.properties file, and for TransSECS deployments (and also for MIX applications running TransSECS code) you can add a parameter to ErgoTechConfiguration.properties.
Line 37: Line 39:
  
 </code> </code>
 +
 +==== Store Parameters in a Variable ====
 +
 +If you are going to use this parameter in your project's scripting often, you can store this value in a "Variable" in the /Devices/Utility_Servers node of your project. 
 +
 +Add a "Variable" (BroadcastServer) to your Utility_Servers, for example add a Variable called "IPAddress". Taking the code from the example above, after reading the value for ipAddrss, you can store it in this new Variable for later access. Alternatively you can just use System.getProperty() again to get this value whenever you need to.
 +
 +<code javascript>
 +var System = Java.type("java.lang.System");
 +
 +ipAddress=System.getProperty("ipaddress"); //ipAddress will be null if "ipaddress" is not defined
 +
 +if (ipAddress!=null) {
 + //store the ipAddress in the Variable "IPAddress" for access later
 +   /Devices/UtilityServers_Servers/IPAddress->setStringValue(ipAddress);
 +}
 +
 +</code>
 +
 +Any time after this in your scripts you can access the current value of "IPAddress" using the syntax ipAddress=/Devices/UtilityServers_Servers/IPAddress->getStringValue();
accesssystempropertiesinscript.1673732773.txt.gz · Last modified: by wikiadmin

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki