Maybe what you want is a couple of conversion routines in a service
program. If you have different field sizes and different number of
decimals it becomes a bit more complex. Conceptually:
Scr_Fld = DecToChar(NumFld, Decimals, OutLen);
NumFld in the procedure definition would be defined as something like
packed 31,15, or if you never go above 5 decimals then 31,5, and the
compiler would convert from the actually field in the calling program.
In the procedure you'd need a case statement to pick out a correct
%EDITC or %EDITW statement with the correct number of decimals and
finally end up with a right aligned char work variable.
Then substring that back to the output field.
Wk_Num_Fld = CharToDec(Scr_Fld, Decimals, InLen, ErrorMsg);
Wk_Num_Fld in the calling program would always be defined as 31, 15, or
whatever you maximum decimal places are.
You'd do whatever editing necessary to end up with the correct number of
decimal digits and end up with an internal work variable that is packed
31, 15, which you would return. The calling program would be
responsible for moving that to a correctly sized field.
ErrorMsg would be blank on a successful conversion, non-blank if there
was bad data.
I must stress that no coding has been done here and I've usually found
that it turns out to be more complex than the design document. But
maybe it will spark some other suggestions. And if it could be pulled
off you'd have all the logic in one place.
Or you might want to write a separate, but similar routines, for each
number of decimal places, to keep the interface simpler.
Wk_Num_Fld = CharToDec2(Scr_Fld, InLen, ErrorMsg);
Wk_Num_Fld = CharToDec3(Scr_Fld, InLen, ErrorMsg);
etc;
Actually, if you defined Scr_Fld as varying, you could probably drop the
InLen parm:
Wk_Num_Fld = CharToDec2(Scr_Fld, ErrorMsg);
OK, now I'm beginning to ramble...
Sam
On 7/13/2010 11:30 AM, Timothy Adair wrote:
I could
define the screen field as alpha but that gets ugly because I have to
translate both directions. And we're talking about dozens of fields
across hundreds of programs. That's why I'm looking for a simple solution.
As an Amazon Associate we earn from qualifying purchases.