× 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.



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.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 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.