|
And for another matter entirely different, here is my solution, taken from another list and modified slightly: HNoMain HOption(*SrcStmt) D CvtCharToNum PR N D 40 Value D 30 9 *-------- * CvtExtFrmToNum - Convert External Form to Numeric Value * Receiver variables Output * Receiver Attributes Input * Source String Input * Source String Length Input * Symbol Mast Input *-------- D CvtExtFrmToNum PR ExtProc('_CVTEFN') D * VALUE D 7 CONST D * VALUE D 10U 0 CONST D 3 CONST D 3 CONST *------ * CvtCharToNum - Convert Character to Numeric *------ PCvtCharToNum B Export D D PI N D String 40 Value D Number 30 9 *-------- * Data Definitions *-------- D RcvAttr DS D Type 1 Inz(X'03') D NbrLen 5I 0 D DecPos 3I 0 Overlay(NbrLen:1) D TotDigits 3I 0 Overlay(NbrLen:2) D 10I 0 INZ(*ZERO) D digits c '0123456789' D D mask c '0123456789$,.-+ ' D SymbolMask DS D CurSymbol 1 Inz('$') D ComSymbol 1 Inz(',') D DecPntSymbol 1 Inz('.') *-------- * Convert Character String to Packed Numeric Format *-------- C Eval Decpos = %DecPos(Number) C Eval TotDigits = %Len(Number) C C if %check(mask : string) > *zeros C return *on C endif C C CallP CvtExtFrmToNum( C %Addr(Number) : C RcvAttr : C %Addr(String) : C %Len(%TrimR(String)) : C SymbolMask ) C Return *Off *------- * Return Error condition for any error *------- C *PSSR BegSr C C eval number = *zeros C Return *On C C EndSr PCvtCharToNum E -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Paul Morgan Sent: Friday, July 29, 2005 8:12 AM To: rpg400-l@xxxxxxxxxxxx Subject: Re: Converting packed values in a buffer Grizzly, Here's a code snippet for a procedure that will convert a character string to a packed number: http://code.midrange.com/index.php?id=b3ae0de366 Paul
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.