Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: BDS - Genero Migration - Scaling / WHENEVER  (Read 11244 times)
Stephen T.
Posts: 114


« 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).
Reuben B.
Four Js
Posts: 1126


« Reply #1 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.

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Nuno G.
Posts: 38


« Reply #2 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!
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines