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



I have a function that calls iconv, in one module, called by a main program in another module. It works the first time, but it fails on subsequent calls.

In the called module, I have global static buffers defined thusly (white space squeezed out to avoid line breaks):

D DS
D BUFFY 1 500000A
D BUFFA 1 500000A DIM(500000)
D BUFLEN S 10I 0
D MUFFY S 500000A
D MUFLEN S 10I 0 INZ(500000)

and I have parameters for iconv defined thusly:

D QtqCode_T Ds
D Qtq_CcsId 10i 0
D Qtq_CnvAlt 10i 0 Inz( 0 )
D Qtq_ShfSttAlt 10i 0 Inz( 0 )
D Qtq_InpLenOpt 10i 0 Inz( 0 )
D Qtq_ErrOptMxd 10i 0 Inz( 0 )
D Qtq_Rsv 8a Inz( *Allx'00' )
**
D fromcode s Like( QtqCode_T )
D tocode s Like( QtqCode_T )
**
. . .
D pBUFFY s * Inz(%Addr(BUFFY))
D pMUFFY s * Inz(%Addr(MUFFY))

At the top of the procedure, I'm clearing BUFFY, BUFLEN, and MUFFY, and reinitializing MUFLEN to 500000, the length of MUFFY. Then, once I have a UTF-8 value in BUFFY, I have:

C Eval Qtq_CcsId = 1208
C Eval fromcode = QtqCode_T
C Eval Qtq_CcsId = 37
C Eval tocode = QtqCode_T
**
C Eval iconv_t = IconvOpen( %Addr( tocode )
C : %Addr( fromcode )
C )
**
C EVAL RC = ICONV(ICONV_T:
C pBUFFY:
C BUFLEN:
C pMUFFY:
C MUFLEN)
C EVAL RC = ICONV_CLOSE(ICONV_T)
C EVAL BUFFY = MUFFY
C EVAL BUFLEN = %LEN(%TRIM(BUFFY))

I then go on to parse the translated buffer

The main program calls this procedure three times. The first time, it works fine. The second time, it comes back with MUFFY completely blank.

I just tried adding statements to reinitialize pBUFFY and pMUFFY at the top of the procedure; no change.

I have no idea what I could be doing wrong here.

--
JHHL

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.