× 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 wrote:
>I have an IFS service program with the following procedure:
>
>p IFS_prt         b                   export
>
>d IFS_prt         pi
>d  hFile                              like(int) value
>d  Text                      32766a   value
>
>d Data            s          32766a
>d NbrWritten      s                   like(int)
>
>c                   eval      Data = %trimr(Text)
>c                   eval      NbrWritten = api_write(
>c                                          hFile:
>c                                          %addr(Data):
>c                                          %len(%trimr(Data)))
>
>p                 e
>
>And I use it in an RPGLE (V4R5) program like this:
>
>d CnvRec          s            128a
>
>c                   eval      CnvRec = 'GL CONVERSION ' + @TapeID + x'25'
>c                   callp     IFS_prt(hCnvFile:CnvRec)
>
>Note the disparity in lengths of CnvRec and Text.
>
>The manual (Title: ILE RPG for AS/400 Reference; Document Number:
>SC09-2508-02) states that:
>
>"The rules for what can be passed as a value parameter to a called
procedure
>are the same as the rules for what can be assigned using the EVAL
operation.
>The parameter received by the procedure corresponds to the left-hand side
of
>the expression; the passed parameter corresponds to the right-hand side.
See
>"EVAL (Evaluate expression)" in topic 4.4.36 for more information."
>
>To me that sounds like it's effectively doing an EVAL TEXT = CNVREC in the
>above example.  If that's true, then TEXT should be padded with blanks
after
>the x'25'. Instead, starting at pos.1025, it has some junk, then repeats
the
>value in CnvRec.
>
>So what's the real story with the VALUE option?

Did you check the values using the debugger?  As coded, the
VALUE parameter should work fine, albeit inefficiently.  The
recommended way to pass string parameters is using CONST
VARYING, not by fixed length value parameters.

Furthermore, your statement "EVAL Data=%trimr(Text)" is
essentially a (very slow) no-op:  You're trimming the
trailing blanks off the string.  But when you assign the
value to another fixed length string variable, the value is
padded on the right with more blanks!

Regarding your bug, I don't think it's due to the coding of
the VALUE parameter.  It must be somewhere else.

Cheers!  Hans

Hans Boldt, ILE RPG Development, IBM Toronto Lab, boldt@ca.ibm.com



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.