|
"mlazarus@xxxxxxxx" wrote: > ... > Since I'm returning an alpha string, I want to place the proper number of > digits in the return field. So the idea was to be able to handle it > something like this: > > ReturnData = EditC( %DecH( AtoF( InputString ) :VaryingLength: DecLength > ):'X' ) > > This won't work, since VaryingLength and DecLength would not be known at > compile time. > > Of course, I can handle it w/ %SubStr(), but I think that being able use > the combination of defining the numric size of the fly and then using an > edit code is MUCH more elegant. > ... Sounds like a job for a procedure: ReturnData = ReEditNum (InputString : VaryingLength : DecLength) The procedure could using %DECH(inputString:31:9) into a zoned subfield and then do substringing on the data structure. Since you're using the X edit code, I assume you don't care about the difference between 1.2 and 12. If so, you could XLATE out the decimal point and use %DEC(string : 31 : 0). ReturnData = %Subst(%Editc(%Dec(%Xlate('.':' ':string) : 31 : 0) : 'X') : 31 - VaryingLength + 1) (Ewww ...) By the way, %DECH handles decimal strings better than atof(), especially if you suspect invalid data. atof() doesn't give an error, it just takes what it can use and ignores the rest.
As an Amazon Associate we earn from qualifying purchases.
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.