Four Js Development Tools Forum

Discussions by product => Genero BDL => Topic started by: Stephen T. on October 24, 2013, 01:00:59 pm



Title: BDS - Genero Migration - Scaling / WHENEVER
Post by: Stephen T. on October 24, 2013, 01:00:59 pm
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).


Title: Re: BDS - Genero Migration - Scaling / WHENEVER
Post by: Reuben B. on October 25, 2013, 07:06:27 am
That code extract is a bit scary.  I think something like this shows the subtle difference...

Code
  1. MAIN
  2. DEFINE x DECIMAL(6,2)
  3.  
  4.    LET x= 9999.99 + 1
  5.    DISPLAY "Value is ",x
  6.  
  7.    WHENEVER ANY ERROR STOP
  8.    LET x= 9999.99 + 1
  9.    DISPLAY "Value is ",x
  10. END MAIN

On BDS displays 10000.99 for both

On Genero displays NULL and stops.


Title: Re: BDS - Genero Migration - Scaling / WHENEVER
Post by: Nuno G. on October 25, 2013, 05:42:37 pm
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!