Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert Hexidecimal into a Character

Status
Not open for further replies.

USADarts

Programmer
Dec 20, 2004
21
US
I am populating a file with Spool File Attribute information. The file number is force into the field as Binary/Hexidecimal. All I see if a highlighted field. The hex values are correct. I need a way to convert this field into a readable character field.

Thanks
 
There is a C runtime function for that (and another one that converts the other way):

Code:
     H BNDDIR('QC2LE') DFTACTGRP(*NO)
     H OPTION(*SRCSTMT : *NODEBUGIO) 

                                                                  
      ** External call prototypes from C runtime library:         
      * Hex to Character                                          
     D  Cvthex_2_To_1  PR                  EXTPROC('cvtch')       
     D   Tgt                      16383A   OPTIONS(*VARSIZE)      
     D   Src                      32767A   CONST OPTIONS(*VARSIZE)
     D   Src_Bytes                   10I 0 VALUE                  
                                                                  
      * Character to Hex                                          
     D  Cvthex_1_To_2  PR                  EXTPROC('cvthc')       
     D   Tgt                      32767A   OPTIONS(*VARSIZE)      
     D   Src                      16383A   CONST OPTIONS(*VARSIZE)
     D   Tgt_Bytes                   10I 0 VALUE                  

      /free
        Hexlen = %LEN(%TRIMR(Hexstring));             
                                    
        Cvthex_2_To_1 (Chstring : Hexstring : Hexlen);

Tibi gratias agimus quod nihil fumas.

 
I tried this and it is not compiling correctly:
Code:
H DftActGrp(*No) ActGrp('QILE') BndDir('QC2LE')                      
D HEX             s             64A   Inz('C1C2C3C4')                
D CHR             s             32A                                  
D Length          s             10i 0                                
D Hex2Chr         Pr                  ExtProc('cvtch')               
D  Tgt                       16383A   Options(*VarSize)              
D  Src                       32767A   Options(*VarSize)              
D  SrcLen                       10i 0 Value                          
D Chr2Hex         Pr                  ExtProc('cvthc')               
D  Tgt                       32767A   Options(*VarSize)              
D  Src                       16383A   Options(*VarSize)              
D  TgtLen                       10i 0 Value                          
   /Free                                                             
      Hex2Chr(Chr:Hex:%len(%trimr(hex)));                            
      Return;                                                        
   /End-Free

Here is the compile error:
Form-Type entry for main procedure not valid or out of sequence.
 
Does the / in /Free start in Column 7?

Tibi gratias agimus quod nihil fumas.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top