NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

check limits "Error -17308; Specified value does not have the expected type."

I'm getting this error when I run a numeric limit step. It happens to be a no adapter step, I'm just checking that another step which was doing some math yields an anwer in a certain range. I'm using a very similar set of steps in another sequence (just different variables) but this is the only one that is throwing the error. Does anybody know what might cause this? Thanks in advance.

0 Kudos
Message 1 of 4
(3,957 Views)

One or more of your variables likely are the wrong data type. What are the data types of your variables?

 

Also, make sure you check the data source tab incase you have customized that setting.

 

-Doug

Message 2 of 4
(3,943 Views)

The problem seems to be that in the Post expression I was setting a variable equal to the addition of two other variables (they were numbers in string format) and Teststand doesn't seem to like that. So I subtracted the variables and multiplied the subtracted variable by -1, and it seems to work.

 

x=y+z -> x=y-z*(-1)

 

Any idea why that is the case?

0 Kudos
Message 3 of 4
(3,932 Views)

What you are seeing is because the '+' operator for strings means string concatenation, not addition.

 

It's best not to rely on TestStand's automatic type conversion because you can get unexpected results. For example:

 

Locals.Str1 = "4"

Locals.Str2 = "5"

Locals.Num = Locals.Str1 + Locals.Str2

 

Unexpectedly gives you 45 for the value of Locals.Num rather than 9 because the '+' first concatenates the strings and the result is then converted into a number.

 

You should instead explicitly convert your strings to numbers using the Val() expression function as follows:

 

Locals.Num = Val(Locals.Str1) + Val(Locals.Str2)

 

Or perhaps, better yet, don't store numbers in strings if you can avoid it, return them from your code modules as the actual numeric type. If you need to convert a number to a string in teststand you can use the Str() expression function.

 

Hope this helps,

-Doug

0 Kudos
Message 4 of 4
(3,899 Views)