×
The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.
Here is the prodecure that worked for the current report (I didn't
exhaustively test it). This procedure will format a large number to fit into
a smaller variable (shrink variable size for printing).
The key calc is setting the max value (thanks Jonathan for remembering your
algebra!). It uses exponential notation to calculate a number that is just
bigger than the target and then subtracts the amount that will return all
nines for the right size of the print field. A quick review of some algebra
web pages reveals that any number (except 0) with exponent 0 is defined as
1. This allows the calc to work for zero decimal positions. A negative
exponent for the number ten will have that many decimals in the result
(-1=.1, -2=.01, -3=.001, etc).
For example:
Size of Fld Num of Dec maxValue Calc
%len(field) %decpos(field) (10 ** (length-decPos))-(10 ** (-1 * (decpos)))
1 0 (10**1)-(10**0) =10-1 =9
7 0 (10**7)-(10**0) =10,000,000-1=9,999,999
7 1 (10**6)-(10**-1)=1,000,000-.1=999,999.9
7 4 (10**3)-(10**-4)=1000-.0001 =999.9999
3 3 (10**0)-(10**-3)=1-.001 =.999
Mike Krebs
//--------------------------------------------------
// Procedure name: GetPrintVal
// Purpose: Set print value according to size of field
// Returns: Print value
// Parameter: inValue => Value to check
// Parameter: length => Length of print field
// Parameter: decPos => Decimal positions
//--------------------------------------------------
D GetPrintVal PR 60P10
D inValue 60P10 CONST
D length 5I 0 CONST
D decPos 5I 0 CONST
//--------------------------------------------------
// Procedure name: GetPrintVal
// Purpose: Set print value according to size of field
// Returns: Print value
// Parameter: inValue => Value to check
// Parameter: length => Length of print field
// Parameter: decPos => Decimal positions
//--------------------------------------------------
P GetPrintVal B
D GetPrintVal PI 60P10
D inValue 60P10 CONST
D length 5I 0 CONST
D decPos 5I 0 CONST
// Local fields
D maxValue S 60P10
D minValue S 60P10
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact
[javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.