NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I programatically set/get a variable's numeric format 'type' from C#?

Solved!
Go to solution
The Numeric Format dialog in TestStand allows me to set the type of a number between "Hexadecimal", "Binary" and "Octal".  How can I do this from C#?  Also, how can I read the current type value?  I am using C# 2008 and TestStand 4.1.
0 Kudos
Message 1 of 6
(6,582 Views)

Hello,

"Hexadecimal", "Binary" and "Octal" are not types they are representations.

 

It's just the way You as the human would prefer to read the value. You don't have to do anything extra ordinary to change that representation in TestStand. So if you create a numerc in .NET(i.e. Int32 value = 255; ) and set it's representation to Hex in TestStand, test stand will display it for you as 0xff.

 

The same is for C# language:

Int32 value = 0x00FF;

 

means exactly the same to the compliler as

 

Int32 value = 255;

 

The representation is only a matter of choice of how you want to view the value it's not the value type.

Hope this helps,

Maciej


0 Kudos
Message 2 of 6
(6,567 Views)

teststand numeric format.JPG

 

Maciej-

Yes, I realize TestStand stores everything as an Int32 but it affects how the number is displayed in the test report.  The value 255 will be displayed as 255 in decimal, 0xFF in hex, 0c377 in octal and 0b11111111 in binary.  I need to allow my users to change the way a number is displayed at runtime depending on their needs.  TestStand allows this to be statically set from the SequenceEditor Variables tab (see attachment) and I want to do the same thing programatically.  I was using TestStand's name "type" from this dialog for what you are calling "representation". 

 

 

 

0 Kudos
Message 3 of 6
(6,562 Views)
Solution
Accepted by topic author skribling

Hi,

-------

Maciej-

Yes, I realize TestStand stores everything as an Int32 but ......

-------

 

As I know, TestStand stores very number as 8byte floating point (double) 

 

To get the format types would use PropertyObject.NumericFormat

or PropertyObject.GetFormattedValue

 

Hope this helps

 

Juergen

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
Message 4 of 6
(6,558 Views)

Sorry, I misunderstood your intention,

j_dodek seems to have properly understood you and he gave you the good answer.


0 Kudos
Message 5 of 6
(6,550 Views)

Maciej, Juergen-

 

Thanks for the suggestions. 

 

PropertyObject.NumericFormat works great for setting the 'type'.  I had played with this prior to posting the question but now I see I had an error in the format string making me think it wasn't working.

 

PropertyObject.GetFormattedValue will give me the 'type' of the Number variable as long as the "Show Radix Prefix" is checked in the Numeric Format dialog since this will include the radix in the formatted string... "0x, 0c or 0b".  I can then look to see which format the data is in.  This isn't quite as foolproof as actually being able to read the 'type' that is set directly from the API but should be a suitable workaround.

 

Steve

0 Kudos
Message 6 of 6
(6,537 Views)