Cecil
19+ years progress programming and still learning.
Hi Guys.
This should be simple. I'm wanting to fetch the 'highs' and 'lows' of a series of values but I don't want to present a zero value for either high or lows.
This is what I have done as a prototype, but it does not look very elegant, nor efficient. How could it be made better?
This should be simple. I'm wanting to fetch the 'highs' and 'lows' of a series of values but I don't want to present a zero value for either high or lows.
This is what I have done as a prototype, but it does not look very elegant, nor efficient. How could it be made better?
Code:
DEFINE VARIABLE deNumber AS DECIMAL NO-UNDO.
DEFINE VARIABLE deMaxValue AS DECIMAL NO-UNDO.
DEFINE VARIABLE deMinValue AS DECIMAL NO-UNDO.
DEFINE VARIABLE deNUMBERS AS DECIMAL NO-UNDO EXTENT 7.
DEFINE VARIABLE iLoop AS INTEGER NO-UNDO.
ASSIGN
deNUMBERS[1] = 0
deNUMBERS[2] = .0579345088
deNUMBERS[3] = .0579345088
deNUMBERS[4] = .0579345088
deNUMBERS[5] = .0502793296
deNUMBERS[6] = .0346715328
deNUMBERS[7] = .029455081
.
DO iLoop = 1 TO EXTENT(deNUMBERS):
IF deNUMBERS[iLoop] NE 0 THEN
deMaxValue = MAXIMUM (deMaxValue, deNUMBERS[iLoop] ).
END.
/** Do it again for the minimum value**/
deMinValue = deMaxValue.
DO iLoop = 1 TO EXTENT(deNUMBERS):
IF deNUMBERS[iLoop] NE 0 THEN
deMinValue = MINIMUM (deMinValue, deNUMBERS[iLoop] ).
END.
MESSAGE
deMinValue skip
deMaxValue
VIEW-AS alert-box info.