DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Setting precision format for variables or in STATS...

I need to be able to format variables so that they only have a certain number of decimal places.  I know you can use a rounding function but it is for about 90 variables so that would not be an efficient way to accomplish this.  Is there a way when global dimensioning variables to set a precision factor or can you set while doing STATS like for average or stdev?? Help appreciated.
0 Kudos
Message 1 of 5
(3,675 Views)
Hi BW_Cummins,
 
There is no way to set an internal precision property of a DIAdem variable or a VBScript variable.  You can of course format the display of that variable with the "str()" function, which you can include as an embedded expresion in a REPORT layout (text box, Axis lable, legend, etc.).  You can also declare DIAdem real variables as either DBL or SGL, so that would set a certain maximum precision, but that doesn't sound like what you want.
 
Let me know if you need something other than display formatting,
Brad Turpin
DIAdem Product Support Engineer
National Instruments
0 Kudos
Message 2 of 5
(3,663 Views)
Say my variable is "myvar" and i want it displayed to 4 decimal places what would i type in a text box on the report window?
0 Kudos
Message 3 of 5
(3,659 Views)
Hi BM_Cummins,

In general a variable, declared with DIM only exists as long as the script is running. To use variables that exists as long as DIAdem is running you can use the register variables R1...R30, L1...L30 etc, declare some in a file (VAS) or declare them with the DIAdem command GLOBALDIM (coming with DIAdem 9.1)

Example:

GlobalDim("myvar")
myvar = 1.23456789

Than you can use t STR formatting (in your case 4 digits) in REPORT as follows:

Data: @@str(myvar, "d.dddd")@@

Please refer to the help for more details.

Greetings

Walter
0 Kudos
Message 4 of 5
(3,648 Views)
I got it all figured thanks for all the help.
0 Kudos
Message 5 of 5
(3,638 Views)