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


  • Subject: Re: Character to Decimal
  • From: "Carsten Flensburg" <flensburg@xxxxxxxxxx>
  • Date: Fri, 18 Aug 2000 15:55:51 +0200
  • Organization: Novasol Data AS


----- Original Message ----- 
From: "Richard Jackson" <richardjackson@richardjackson.net>
To: <RPG400-L@midrange.com>
Sent: 18. august 2000 07:59
Subject: RE: Character to Decimal


> I looked at both cvtefni and cvtefnd before sending my note.  I didn't like
> the looks of either version so I didn't talk about them.
> 
> The CVTEFN MI instruction has all the goodness of being implemented below
> the MI.  Can we write a routine in MI and make it bindable

Hi Richard,

Here's an RPG/IV version using the equivalent _CVTEFN builtin:

     ** Valid source string symbols:
     **   One sign symbol . :  - or +
     **   Decimal point . . :  .
     **   Comma . . . . . . :  ,
     **   Blank . . . . . . :  x'40
     **   Digit . . . . . . :  x'F0' - x'F9'
     **   Currency symbol as defined by mask
     **
     D T_SIGNED        c                   x'00'
     D T_FLOAT         c                   x'01'
     D T_ZONED         c                   x'02'
     D T_PACKED        c                   x'03'
     D T_UNSIGNED      c                   x'0A'
     **
     D Mask            Ds
     D  CurSym                        1a   Inz( '$' )
     D  ComSym                        1a   Inz( ',' )
     D  DecPntSym                     1a   Inz( '.' )
     **
     D DPA_Template_T  Ds
     D  SclTyp                        1a
     D  RcvLen                        5i 0
     D   DecPos                       3i 0 Overlay( RcvLen: 1 )
     D   TotDig                       3i 0 Overlay( RcvLen: 2 )
     D  Rsv                          10i 0 Inz
     **
     D CVTEFN          Pr                  ExtProc( '_CVTEFN' )
     D  RcvVar                         *   Value
     D  RcvAtr                             Const  Like( DPA_Template_T )
     D  Source                         *   Value
     D  SrcLen                       10u 0 Const
     D  SymMsk                             Const  Like( Mask )
     **
     D Source          s             25a   Inz( '-12,345,678.912' )
     D Packed          s             15p 4
     D Binary          s             10i 0
     **
     **-- Zoned & Packed:
     C                   Eval      SclTyp     = T_PACKED
     C                   Eval      DecPos     = %DecPos( Packed )
     C                   Eval      TotDig     = %Len( Packed )
     **
     C                   CallP     CVTEFN( %Addr( Packed )
     C                                   : DPA_Template_T
     C                                   : %Addr( Source )
     C                                   : %Len( %TrimR( Source ))
     C                                   : Mask
     C                                   )
     **-- Binary & Float:
     C                   Eval      SclTyp     = T_SIGNED
     C                   Eval      RcvLen     = %Size( Binary )
     **
     C                   CallP     CVTEFN( %Addr( Binary )
     C                                   : DPA_Template_T
     C                                   : %Addr( Source )
     C                                   : %Len( %TrimR( Source ))
     C                                   : Mask
     C                                   )
     **
     C                   Return
     **

I haven't made any performance tests though, maybe someone else will check out 
the cpu-consumption of the various routines?!

Best regards,
Carsten Flensburg

+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.