Dynamic Decimal format in browse

In a browse, I display the following fields :

field1
field2
field3
ROUND(field4,x)
.
.
.

Where 'x' is an integer value (this is the dynamic point).

The problem comes from what the Browse is printing. The 'rounded' decimal values are always formatted with 2 digits, whatever the x value is :

1.00
0.53
0.44

So I tried to display the following :

field1
field2
field3
STRING(ROUND(field4,x))
.
.
.


The result is a bit better , but still not perfect , as it still misses some filling zeros :

1
.534
.44

I also tried to had a dynamic format to the string function but it doesn't work (always returning an empty string)


field1
field2
field3
STRING(ROUND(field4,x),cformatstring)
.
.
.

How can I obtain this good formatting in my browse :

1.000
0.534
0.440

?
 
You won't be able to dynamically assign the string format without some messing around.

The best way I can suggest is to use substring and string functions to re-construct the value how you want it.

Alternatively, since there are a limited number of options you could use a case statement

e.g.
case x:
when 1
then displayval = string(round(field4, 1), "zz9.9")
when 2
then displayval = string(round(field4, 2), "z9.99")
...
...
end case.
 

cecsno

Member
Olivier_Desmars said:
In a browse, I display the following fields :

field1
field2
field3
ROUND(field4,x)
.
.
.

Where 'x' is an integer value (this is the dynamic point).

The problem comes from what the Browse is printing. The 'rounded' decimal values are always formatted with 2 digits, whatever the x value is :

1.00
0.53
0.44

So I tried to display the following :

field1
field2
field3
STRING(ROUND(field4,x))
.
.
.


The result is a bit better , but still not perfect , as it still misses some filling zeros :

1
.534
.44

I also tried to had a dynamic format to the string function but it doesn't work (always returning an empty string)


field1
field2
field3
STRING(ROUND(field4,x),cformatstring)
.
.
.

How can I obtain this good formatting in my browse :

1.000
0.534
0.440

?

Try defining a decimal variable with a format of >>9.999 or what ever you need and display it at field4.

display v-deci @ field4 with browse browse name.

V9 Help for define browse.

You can modify the field values displayed in the current iteration of a browse by using the WITH BROWSE option of the DISPLAY statement.
SYNTAX
DISPLAY { field | { value @ field } } ...
WITH BROWSE browse
 
Top