accesssystempropertiesinscript
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| accesssystempropertiesinscript [2023/01/14 16:33] – created wikiadmin | accesssystempropertiesinscript [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===== | ||
| + | |||
| + | < | ||
| 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, | 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, | ||
| Line 9: | Line 11: | ||
| System properties are read as Strings. So if you have a variable in your application which is a numeric value you can do a numeric conversion on the String. Be sure to use a numeric value such as " | System properties are read as Strings. So if you have a variable in your application which is a numeric value you can do a numeric conversion on the String. Be sure to use a numeric value such as " | ||
| - | ==== Access the Property Value ==== | + | ==== Access the Command Line Property Value ==== |
| The general idea to access these properties is to use System.getProperty(" | The general idea to access these properties is to use System.getProperty(" | ||
| Line 18: | Line 20: | ||
| ipAddress=System.getProperty(" | ipAddress=System.getProperty(" | ||
| - | //now the ipAddress can be used to set the ip address of a device server | + | //now the ipAddress |
| - | myDeviceServer->setHostName(ipaddress); | + | DeviceServer->setAddress(ipAddress); //note: setAddress method may be setHostname in some device servers |
| </ | </ | ||
| Line 33: | Line 35: | ||
| if (ipAddress!=null) { | if (ipAddress!=null) { | ||
| - | myDeviceServer->setHostName(ipaddress); | + | DeviceServer->setAddress(ipAddress); |
| } | } | ||
| </ | </ | ||
| + | |||
| + | ==== Store Parameters in a Variable ==== | ||
| + | |||
| + | If you are going to use this parameter in your project' | ||
| + | |||
| + | Add a " | ||
| + | |||
| + | <code javascript> | ||
| + | var System = Java.type(" | ||
| + | |||
| + | ipAddress=System.getProperty(" | ||
| + | |||
| + | if (ipAddress!=null) { | ||
| + | // | ||
| + | / | ||
| + | } | ||
| + | |||
| + | </ | ||
| + | |||
| + | Any time after this in your scripts you can access the current value of " | ||
accesssystempropertiesinscript.1673732033.txt.gz · Last modified: by wikiadmin
