BDS - Genero Migration - Scaling / WHENEVER

Started by Stephen T., October 24, 2013, 01:00:59 PM

Previous topic - Next topic

Stephen T.

BDS - 3.55.01.40 Genero 2.40.03

This code extract shows the issue:
DEFINE l_char                  CHAR(1),
        l_i                     INTEGER,
        l_total                 DEC(8,2)

-- SCALING and WHENEVER test.......   
WHENEVER ERROR STOP
    LET l_total = 0
    WHILE l_total IS NOT NULL AND l_total < 20000000
        LET l_total = l_total + ((MONTH(TODAY)/DAY(TODAY)) * YEAR(TODAY))
        DISPLAY 'Total IS (',l_total,')'
    END WHILE      --

    PROMPT 'Finished WHENEVER ERROR Test With Total (',l_total,')' FOR CHAR l_char
WHENEVER ANY ERROR STOP
    LET l_total = 0
    WHILE l_total IS NOT NULL
        LET l_total = l_total + ((MONTH(TODAY)/DAY(TODAY)) * YEAR(TODAY))
        DISPLAY 'Total IS (',l_total,')'
    END WHILE     

In BDS, the  WHILE loops have to be terminated - the value of l_total simply increases (the 20,000,000 limit is there in the first loop to cause it to stop so the code will continue with the second test), eventually appearing in scientific notation.
In Genero, and this is documented, once l_total exceeds its scale (precision?) - ie above 999999.99 , it goes NULL in the first loop and then causes the program to stop in the second. IE it works 'correctly'.

The migration here had code without any WHENEVER clause.  This then manifested itself in variety of situations - totals , array (subscript) (array bounds checking not being turned on).

Reuben B.

That code extract is a bit scary.  I think something like this shows the subtle difference...

Code (genero) Select
MAIN
DEFINE x DECIMAL(6,2)

    LET x= 9999.99 + 1
    DISPLAY "Value is ",x

    WHENEVER ANY ERROR STOP
    LET x= 9999.99 + 1
    DISPLAY "Value is ",x
END MAIN


On BDS displays 10000.99 for both

On Genero displays NULL and stops.
Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero

Nuno G.

I believe to recall to see this issue in the bdl manual. But you are right, it is a problem. I spent a couple of hours debbuging a map untill i figure out what was going on, since I was missing a column whit no aparent reason.

I ended up by resizing the dec va r to avoid the overflow, but that nothing but a (bad ) patch!