[NEWSboard IBMi Forum]

Thema: Hex mit RPG ?

Hybrid View

  1. #1
    Registriert seit
    Apr 2008
    Beiträge
    2

    Hex mit RPG ?

    Hallo zusammen,
    Ich hatte mit RPGIII noch nie was mit Hex gemacht und habe folgendes Problem:

    Mein RPG Programm liest eine Zahl aus einer Datei, z.B. '2008' und diese sollte ich als Hexwert-Parameter in ein CL weitergeben.

    Kann mir jemand ein Beispiel geben ?

    Tausendfachen Dank
    A.Gutknecht

  2. #2
    Registriert seit
    Aug 2004
    Beiträge
    923
    Another cool thing about QC2LE is that the ILE C/400 runtime includes the full set of open AS/400 MI instructions. That is the AS/400 assembly language can be called directly from RPG IV by prototyping their C/400 functions. For example, to call the Convert Characters to Hexadecimal Symbols MI instruction, you would call the 'cvthc' C runtime function. For example:
    The following RPG IV code should compile on any version of OS/400 that includes RPG IV.
    PHP-Code:
    .....DName+++++++++++EUDS.......Length+TDc.Functions++++++++++++++++++
         
    D szCharVal       S             20A   Inz('ABCDEFG')
         
    D szHexVal        DS
         D   szHex1                            LIKE
    (szCharVal)
         
    D   szHex2                            LIKE(szCharVal)
         
    D nCharLen        S              9B 0 
    .....CSRn01..............OpCode(ex)Extended-factor2++++++++++++++++++
         **  if 
    you want to avoid converting trailing blanks, use this stmt.
         
    C     ' '           CheckR    szCharVal     nCharLen
         
    **  or if you want to convert trailing blanks, use this stmt.
         
    C                   Eval      nCharLen = %size(szCharVal) * 2   
    .....CSRn01Factor1+++++++OpCode(ex)Factor2+++++++Result++++++++Len++DcHiLoEq
         
    **  This converts '123' to 'F1F2F3'
         
    C                   CALLB     'cvthc'
         
    C                   Parm                    szHexVal
         C                   Parm                    szCharVal
         C                   Parm                    nCharLen
         
    **  This converts 'F1F2F3' to '123'
         
    C                   CALLB     'cvtch'
         
    C                   Parm                    szCharVal
         C                   Parm                    szHexVal
         C                   Parm                    nCharLen 
    Just a few things to remember when using the C runtime APIs.
    • The names are case-sensitive. That is 'cvthc' must be specified in lower case or it will not be found.
    • These functions are located in the OS/400 C-runtime library and must be bound using the QC2LE binding directory.
    • Parameters that require pass-by-value restrict the API to being called with newer releases of RPG IV, via procedure prototypes.
    • C functions that have return values cannot be called by RPG IV under OS/400 version 3, release 1.
    • Until you move to V3 R2 or, even better, V3 R7, the number of interfaces that can be accessed by RPG IV is limited. In fact, the HexToChar, CharToHex functions are about all that are useful.
    • Under later releases of RPG IV, procedure prototypes allow access to all of the C runtime functions. This includes those nice little date and time formatting functions, such as asctime.
    For more details and examples of using procedure prototypes with the C runtime library, see the article on interfacing RPG IV with the C/400 language runtime library on the RPG Developer Network News page.
    entnommen von Frequently Asked Questions

    kuempi

  3. #3
    Registriert seit
    Apr 2008
    Beiträge
    2

    Hat geklapp vielen Dank

    Besten Dank für das Beispiel.
    Gruess
    A.Gutknecht

Similar Threads

  1. Rückgabewert vom RPG Programm
    By mk in forum NEWSboard Java
    Antworten: 8
    Letzter Beitrag: 21-04-11, 21:51
  2. Ascii nach Hex konvertieren in RPG
    By TARASIK in forum NEWSboard Programmierung
    Antworten: 1
    Letzter Beitrag: 14-01-08, 09:02
  3. RPG: Client Infos lesen?
    By robertki in forum NEWSboard Programmierung
    Antworten: 25
    Letzter Beitrag: 19-01-07, 08:42
  4. Problem mit Java-Methoden Aufruf aus ILE RPG?
    By Stoeberl in forum NEWSboard Programmierung
    Antworten: 8
    Letzter Beitrag: 10-01-07, 10:58
  5. RPG goes Web
    By jth in forum NEWSboard Programmierung
    Antworten: 1
    Letzter Beitrag: 21-12-06, 11:13

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • You may not post attachments
  • You may not edit your posts
  •