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



You're reading these bytes from a buffer?  What about the Late Bound Copy 
Numeric api?  I'm not sure if it's quite right for your purpose...  It depends 
on what the data looks like in your buffer....

Here's some code by Carsten Flensburg.

     ** See QSYSINC/MIH.MICPTCOM
     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 DPA_Template_T  Ds                  Based( pDPA )
     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
     ** Late bound copy numeric variable:
     D LBCPYNV         Pr                  ExtProc( '_LBCPYNV' )
     D  Target                         *   Value
     D  Target_Tpl                         Const Like( DPA_Template_T )
     D  Source                         *   Value
     D  Source_Tpl                         Const Like( DPA_Template_T )
     ** Late bound copy numeric variable - with rounding:
     D LBCPYNVR        PR                  extproc( '_LBCPYNVR' )
     D  Target                         *   Value
     D  Target_Tpl                         Const Like( DPA_Template_T )
     D  Source                         *   Value
     D  Source_Tpl                         Const Like( DPA_Template_T )
     **
     D SrcTpl          s                   Like( DPA_Template_T )
     D TgtTpl          s                   Like( DPA_Template_T )
     **
     D SrcDs           Ds
     D  Fields25                     25a
     D  P12_3                        12p 3 Inz( -12345678.915 )
     D TgtDs           Ds
     D  Fields38                     38a
     D  S11_2                        11s 2
     **
     D Msg             s             52a
     **
     C                   Eval      pDPA   = %Addr( SrcTpl )
     C                   Eval      SclTyp = T_PACKED
     C                   Eval      TotDig = 12
     C                   Eval      DecPos = 3
     C                   Eval      Rsv    = 0
     **
     C                   Eval      pDPA   = %Addr( TgtTpl )
     C                   Eval      SclTyp = T_ZONED
     C                   Eval      TotDig = 11
     C                   Eval      DecPos = 2
     C                   Eval      Rsv    = 0
     **
     C                   CallP     LBCPYNVR( %Addr( TgtDs ) + 38
     C                                     : TgtTpl
     C                                     : %Addr( SrcDs ) + 25
     C                                     : SrcTpl
     C                                     )
     **
     C                   Eval      Msg = %char( P12_3 ) + ' --> ' +
     C                                   %char( S11_2 )
     **
     C     Msg           Dsply
     **
     C                   return
     **



-Eric

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx]On Behalf Of Holden Tommy
Sent: Friday, March 30, 2007 1:27 PM
To: rpg400-l@xxxxxxxxxxxx
Subject: 


alternative for %DEC? 

i have a issue i'm trying to resolve. basically i want to use something
similar to %DEC. unfortunately you can't use variable values for digits
& precision with %DEC. here is basically what i want to do:
Code:
                 number = %Dec(%trim(%Subst(Data:FieldDS(Ctr).InBuffer:
                          FieldDS(Ctr).Length)):
                          FieldDS(Ctr).Digits:FieldDS(Ctr).Decimals);
instead of using tons of IFs etc. is there a way to do this? unless
someone has a clever answer i'll end up using this kind of garbage:
Code:
  select;
     when FieldDS(Ctr).Decimals = 1;
        number = %Dec(%trim(%subst(data:fieldds(ctr).InBuffer:
               FieldDS(Ctr).Length)):30:1);
     when FieldDS(Ctr).Decimals = 2;
        number = %Dec(%trim(%subst(data:fieldds(ctr).InBuffer:
               FieldDS(Ctr).Length)):30:2);
which is a major pain....wonder if there is a way for the compiler team
to add this functionality???


Thanks,
Tommy Holden




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.