01-13-2011 04:21 AM
I want to assign a value of a station global variable (type: number) to local variable (type: number).
The problem is, that a know the right path of the station global variable at runtime.
I have an string variable like "StationGlobals.PARAMETER.SWITCH.xx.nRESISTOR_VALUE" - the characters "xx" will be replaced at runtime...
Now I want to convert this string variable into a path in order to assign the local variable (type: number) the value of the station global variable (type: number)
Do you know how I can do it?
greetz
Jonathan K.
Solved! Go to Solution.
01-13-2011 05:27 AM
Hi,
are you saying you want to extract what the value of xx and insert into a local or StationGlobal.
or
are you wanting to change the xx to some value in "StationGlobals.PARAMETER.SWITCH.xx.nRESISTOR_VALUE" at runtime
if the latter then you would need to convert the xx as a value to a string such as
"StationGlobals.PARAMETER.SWITCH." + str(locals.switch_value) +".nRESISTOR_VALUE", you would probably have to format the string value using the string format which I think is the second parameter of the function str() if you actually what two characters eg 1 would be "01"
if the first then you would use Locals.Switch = Val(mid("StationGlobals.PARAMETER.SWITCH.xx.nRESISTOR_VALUE", 32, 2))
01-14-2011 05:10 AM
neither ... nor
I try to explain my problem once again:
There are some StationGlobals e.g.
StationGlobals.PARAMETER.SWITCH.MVS.nRESISTOR_VALUE = 220
StationGlobals.PARAMETER.SWITCH.BLS.nRESISTOR_VALUE = 5980
StationGlobals.PARAMETER.SWITCH.HVS.nRESISTOR_VALUE = 580
...
and there is a Local... e.g.:
Locals.nCurrentResistorValue = NaN
Now I want to assign Locals.nCurrentResistorValue one of the StationGlobals. The problem is, that I get the information which of the StationGlobals I have to use at runtime.So I have a Local String Variable e.g.
during development: Locals.sFunctionPath = ""
at runtime: Locals.sFunctionPath = "StationGlobals.PARAMETER.SWITCH.HVS.nRESISTOR_VALUE"
Finally I want to assign Locals.nCurrentResistorValue the value which is behind the Locals.sFunctionPath.
something like:
Locals.nCurrentResistorValue = Val(Locals.sFunctionPath) [= 580]
But this expression doesn't work...
Do you a way I can handle it?
01-14-2011 05:22 AM - edited 01-14-2011 05:23 AM
Try
Locals.nCurrentResistorValue = Evaluate(Locals.sFunctionPath)