星期二, 10月 31, 2023

2001-05-04 如何於RPG中做 Hex(十六位元) to Char (字元)轉換?



如何於RPG中做 Hex(十六位元) to Char (字元)轉換?

File  : QRPGLESRC
Member: CVTHEXCHR
Type  : RPGLE

     h debug dftactgrp(*no) actgrp('QILE') bnddir('QC2LE')
      * dbgview(*list)

      *  The following are the C defintions for the MI function cvtch
      *    - refer to the MI Library Reference on the ILE C bookshelf for f

      *     void cvtch (_SPCPTR receiver,
      *                 _SPCPTRCN source,
      *                 int size););

     D C2H             Pr                  ExtProc('cvtch')
     D  RecPtrP                        *   Value
     D  SrcPtrP                        *   Value
     D  SizeP                        10I 0 Value

     D H2C             Pr                  ExtProc('cvthc')
     D  RecPtrP                        *   Value
     D  SrcPtrP                        *   Value
     D  SizeP                        10I 0 Value

     D RecPtr          S               *   INZ
     D SrcPtr          S               *   INZ

     D OutStrD         S             20    INZ
     D InpStrD         S             10    INZ('F1F2F3')
     D Size            S             10I 0 INZ

     C                   Eval      RecPtr=%Addr(OutStrD)
     C                   Eval      SrcPtr=%Addr(InpStrD)
     C                   Eval      Size=%len(%trim(InpStrD))

     C                   CALLP     C2H(RecPtr :
     C                                 SrcPtr :
     C                                 Size)

     C                   Dump

     C     InpStrD       Dsply
     C     OutStrD       Dsply

     C                   Movel(P)  OutStrD       InpStrD
     C                   Eval      OutStrD=*BLANKS
     C                   Eval      Size=%len(%trim(InpStrD))*2

     C                   CALLP     H2C(RecPtr :
     C                                 SrcPtr :
     C                                 Size)

     C                   Dump

     C     InpStrD       Dsply
     C     OutStrD       Dsply

     C                   SetOn                                          LR





沒有留言: