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



Peter Connell wrote:

>Anybody got a modern routine for converting a 
>character string that has been entered in hex 
>format back to the compressed hex representation. 
>eg a 6 char field 'C1C2C3' input should return a 3 
>char output of 'ABC' , that is X'C1C2C3'.
>I tried the C runtime cvtch and cvthc but they didn't seem to work.

This works for me:
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     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     InpStrD       Dsply                                            
C     OutStrD       Dsply                                            
                                                                     
C                   SetOn                                          LR 

Buck Calabro
Commsoft; Albany, NY
"Nothing is so firmly believed as
 that which we least know" -- Michel Montaigne
Visit the Midrange archives at http://www.midrange.com
+---
| 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 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.