NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

convert a string into a path

Solved!
Go to solution

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.

0 Kudos
Message 1 of 4
(4,472 Views)

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))

 

 

 

 

Regards
Ray Farmer
0 Kudos
Message 2 of 4
(4,468 Views)

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?

 

 

 

 

0 Kudos
Message 3 of 4
(4,445 Views)
Solution
Accepted by topic author JonathanK

Try

 

 

Locals.nCurrentResistorValue = Evaluate(Locals.sFunctionPath)

 

 

Regards
Ray Farmer
0 Kudos
Message 4 of 4
(4,442 Views)