PxPlus User Forum

Twitter Twitter Twitter

Author Topic: numeric data in grid cells: how to round?  (Read 151 times)

PMM_CAI

  • Silver Member
  • ***
  • Posts: 30
    • View Profile
numeric data in grid cells: how to round?
« on: May 06, 2024, 05:22:23 PM »
Using PxP 2022. My question concerns formatting of data in numeric cells in a grid. In Format Definition, I assign a numeric variable name to my column; e.g. Cost. In my supporting program, I set the cost's format mask with

let detail_box.ctl'Column$="Cost",detail_box.ctl'row=0, detail_box.ctl'cellformat$="######0.00-"

In the PxP documentation, the CellFormat property redirects to the documentation about multi-line Fmt$ property, which says "Before being output, the number is rounded to the number of decimal places specified in the format mask." But when I test, it truncates, not rounds. (By the way, the incoming value does not exceed the mask.)

Is there a correct way of having numeric grid cell data round instead of truncate?

Thanks in advance.

Paula McKeever
CAI Software LLC

PMM_CAI

  • Silver Member
  • ***
  • Posts: 30
    • View Profile
Re: numeric data in grid cells: how to round?
« Reply #1 on: May 08, 2024, 07:55:20 AM »
I neglected to mention that I cannot convert the data to string prior to loading the grid. It needs to be numeric so that it gets exported as numeric data to a spreadsheet.

James Zukowski

  • Diamond Member
  • *****
  • Posts: 310
    • View Profile
Re: numeric data in grid cells: how to round?
« Reply #2 on: May 08, 2024, 08:44:49 AM »
Not sure if this would apply... Have you checked out the 'RI' and 'RN' parameters?
James Zukowski
Sr. Developer - J&E

BRAND>SAFWAY
Brand Industrial Services

PMM_CAI

  • Silver Member
  • ***
  • Posts: 30
    • View Profile
Re: numeric data in grid cells: how to round?
« Reply #3 on: Today at 03:17:44 PM »
Thanks James. 'RI' did the trick, although we haven't decided about using it yet, since we don't want the behavior to be used elsewhere, and we might not want to risk turning it on in the pgm and then aborting out before turning it back off. But we are considering it! Thanks again.

Paula McKeever
CAI Software LLC

James Zukowski

  • Diamond Member
  • *****
  • Posts: 310
    • View Profile
Re: numeric data in grid cells: how to round?
« Reply #4 on: Today at 03:34:19 PM »
As a possibility, you could enable it before the load and disable it immediately after. That would minimize the potential crash time.
James Zukowski
Sr. Developer - J&E

BRAND>SAFWAY
Brand Industrial Services