Table Column should use either @n4 or @n10.3 picture depending on the product on that line

Hi folks

A canning factory I program for has always had production quantities as integer (eg 240 cans of a certain product). That is how the program was developed. Now they are selling powdered product as kg to 3dp. So the production or sale quantity may be 48.375 kg. The program works fine, but ity is all in the cosmetics. They do not want to see 240.000 for cans. Forms and Reports are easy to adjust, but I would like to be able to dynamically set the picture in a table without Setting Queue Item to a local vriable.
image

If by “Table” you mean a LIST control (often thought of as a browse)
Then use STYLES, and set the PROPSTYLE:Picture

1 Like

A different approach which might be an option which I used, is to have an additional string field in the table which holds the description and then the description can be displayed on windows and in reports easily.

The reason I did this was when a product was being sold by a unit, if it was just 1 unit, the unit displayed without a plural, if more than one unit, it displayed the unit as a plural.

eg
1 Kg
2 Kgs
instead of
1 Kg(s)
2 Kg(s)

1 Can
10 Cans
instead of
1 Can(s)
10 Can(s)

The string field also meant I had less coding to do if the customer wanted to introduce additional units in the future.
Lazy Programmers Club Pro Tip!

Thanks Mark, I will have a look at that. New to me.

Good idea. Neat way to handle 48.5 kg or 240 Cans in same table field.

You can left the column without picture (or use @s10) and it would show the number unformatted, if it is integer it shows the number without decimal sign and fraction part, if it has fraction part, it shows a dot as decimal separator and minimal fraction part without zeros to the right.

Then you can choose Decimal alignment, but the problem is that it doesn’t align properly the only integer numbers seems to start exactly at the dot position, as can be seen on the image:
Special decimal format

The other option can be to use conditional listbox styles, with the condition: Qty = INT(Qty) Then use picture @n10~.~ Else default picture @n10.3, then Decimal alignment works fine, but a dot is shown on integer values, see the second image:
Special decimal format with styles

You can tie it up with Clarion’s Evaluate() and have a unit table control and format the descriptions and calculations back to a common denominator for that product line. The common denominator or “base unit” is the stock holding figure for accountancy purposes. All other units are derived from or to the base unit.

That’s neat, Federico. Thanks