Aligning data on decimal point


Recommended Posts

Hi,

I have a pop up page with a panel that has a number of variable value components physically aligned vertically so that all the decimal points are underneath each other. All the values are displayed using the Format("%.2f",MyValue) notation. The value from one of the channels can be around 100 so may be 99.25 or 101.25 for example. When I align the Variable value component on a value greater than 100.00 any value below this moves the decimal point as the field seems to align left. any suggestions to how I could keep all the values aligned on the decimal point.

Second question, another data field formatted as above normally has values less than 999.99. As I have limited space I would like to change the format to only 1 decimal place if the values rise above so displaying for example 1234.0. returning to 2 decimal places when the value drops below 1000. Obviously the decimal points will not line up in this case but it would prevent overwriting other data nearby.

Thanks,

Martin

Link to comment
Share on other sites

1) right align the controls. Alignment was added at some point but is not available from the normal Variable Value edit window. Instead you have to open the global properties window (View -> Properties from the main menu) and select the control. Then you'll see an "Align" parameter. 0 = left, 1 = right, 2 = center I believe. Once you set it to non-zero, the component becomes resizable instead of autosizing. I'd create one, then duplicate it to make it easy to align and ensure everything is the same size.

2) use the iif() statement:

iif(myValue >= 1000, format("%.1f",MyValue), format("%.2f",MyValue))

Link to comment
Share on other sites

Hi,

1. I did as you suggested and changed the align value to 1. The hatched box around the variable value changed as though it was resizable but in fact attempting to move the left hand side with the mouse still moves the whole component. As the variable value changes between 2 and 3 figures before the decimal point the component moves just as before. The panel that the Variable Value components are on is coloured yellow so that all the values (which have a foreground colour of blue) write on a yellow background. The background area of the Variable Value component (having set the align property to 1) is now white under all conditions even if I reset the align property back to zero. The spin wheel control for the align property will not reduce the value below 1 although it will increase it above 3. The BackColor property for the component is shown as a black square value = 000000 as are all of the other un-modified Variable value components. Changing the BackColor to a yellow square value = ffff00 restores the background colour to yellow. I am using Terminal Font and the DAQFactory version is 5.84 build 1636. Increasing the left property for the component without adjusting the Right property does re-size the hatched box around the component but the actual characters all move towards the right. Changing the font to Arial which I believe to be a TrueType font does not cure the problem.

2. I tried the inline iff(MeanTPH >= 1000,Format("%.1f",MeanTPH),Format("%.2f",MeanTPH)) as the expression in a Variable value component. Where MeanTPH is a declared global that is calculated from MeanTPH = Mean(TPH[0,ResponseTime]) every time a new value is added to the TPH channel. ResponseTime is also a declared Global variable that has a value typically = 30. The expanded expression box shows the result as C1000 Channel or Function not found. I had originally used the full expression at each point rather than the variable MeanTPH and that gave the same result. Watching all of the values shows they are all as expected so what is wrong with the expression.

Thanks,

Martin

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.