|
Here is an RPG IV snippet for using QDCXLATE. I am posting it here to show David Morris' technique of wrapping a system API within a user-written sub-procedure. If I had done this properly, I would have defined a single string variable prototype and used LIKE on all the other declaration statements, but I was just learning when I wrote this. The benefit of wrapping the system API within my own function (to me) is that I can easily substitute a different system API for QDCXLATE if I need to support multiple code pages or the like. My program always calls A2E, and how A2E does it's work does not matter to the caller. D* Convert ASCII text to EBCDIC text D A2E PR 16A D A2EStrIn 16A D* API to translate a string from ASCII to EBCDIC D QDCXLATE PR Extpgm('QDCXLATE') D XLStrLen 5P 0 D XLStr 16A D XLTable 10A C Eval FICtl=A2E(Char16) PA2E B D* Convert ASCII text to EBCDIC text D A2E PI 16A D A2EStrIn 16A D A2EStrOut S Like(A2EStrIn) D A2EStrLen S 5P 0 D A2ETable S 10 Inz('QEBCDIC') C Eval A2EStrLen=%len(A2EStrIn) C Eval A2EStrOut=A2EStrIn C CallP QDCXLATE(A2EStrLen:A2EStrOut:A2ETable) C Return A2EStrOut PA2E E In RPG/400, this would be something like: C Z-ADD50 FLDLEN 50 Length of text C MOVEL'QEBCDIC 'TBLNAM 10 XLATE table C MOVEL'QSYS' LIBNAM 10 C MOVE WMTXT TEXT 50 C CALL 'QDCXLATE' C PARM FLDLEN C PARM TEXT C PARM TBLNAM C PARM LIBNAM Buck Calabro > -----Original Message----- > From: Ajay Kumar > Sent: Wednesday, August 18, 1999 10:49 AM > To: RPG400-L@midrange.com > Subject: ASCII TO EBCDIC conversion > > Client program is sending ASCII data to server program . I need to > convert it to EBCDIC format before logging it. I am looking for some > API 's > or some procedures to do the conversion. > > > +--- | 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 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.