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


  • Subject: Re: passing numeric data
  • From: Scott Klement <klemscot@xxxxxxxxxxxx>
  • Date: Wed, 8 Mar 2000 10:22:41 -0600 (CST)

This is an interesting question.  

RPG IV can both receive and pass zoned decimal parameters directly.
I'd think that this would solve your problem.

If for some odd reason you MUST be able to handle both zoned and packed
data, you could do it with pointers...    Its a lot of horsing around, but
it SHOULD work.   Theres an example of doing this at the bottom of this
message.  

Have Fun :)

On Wed, 8 Mar 2000, Sam wrote:

> Hi,
> Has anyone had experience with writing new RPG IV code and having to call it
> from RPG II programs?!?  There is a problem passing numeric data from an RPG
> II program, which stores everything internally as zoned while new RPG
> defaults to packed.  When I have RPG IV programs I want to call from both
> RPG IV and RPG II, I end up defining (and sometimes redefining) everything
> as zoned.  Sometimes I have to redefine a field I want to pass just so it
> matches wat the called program is expecting.  Is there any easy way around
> this drawback of interfacing the 2 versions of the same language?  I know
> one solution is to convert the RPG II but this client doesn't want to make
> the effort.
> TIA
> Sam Kanakanui



      ** Example of a program that auto-discriminates between
      **   packed and zoned numeric parameters.
      **
     D p_packed1       S               *   INZ(*NULL)
     D p_packed2       S               *   INZ(*NULL)
     D Packed1         S              7P 0 based(p_packed1)
     D Packed2         S              7P 0 based(p_packed2)

     D p_zoned1        S               *   INZ(*NULL)
     D p_zoned2        S               *   INZ(*NULL)
     D Zoned1          S              7S 0 based(p_zoned1)
     D Zoned2          S              7S 0 based(p_zoned2)

     D                 DS
     D  E_Val                  1      2U 0 INZ(0)
     D  C_Val                  2      2A

     c     *entry        plist
     c                   parm                    parm1             1
     c                   parm                    parm2             2

     C* if the EBCDIC value of the first byte in parm1
     C* is F0 or higher, it must be zoned:
     C*
     c                   eval      C_Val = parm1
     c                   if        E_Val > 239
     c                   eval      p_zoned1 = %addr(parm1)
     c                   else
     c                   eval      p_packed1 = %addr(parm1)
     c                   endif

     C* if the EBCDIC value of the first byte in parm2
     C* is F0 or higher, it must be zoned:
     C*
     c                   eval      C_Val = parm2
     c                   if        E_Val > 239
     c                   eval      p_zoned2 = %addr(parm2)
     c                   else
     c                   eval      p_packed2 = %addr(parm2)
     c                   endif

     C*
     C*  Example of how to know which variable to use,
     C*     In this example, we're just displaying the values
     C*     of parm1 & parm2:
     C*
     c                   if        p_zoned1 = *NULL
     c     'Parm1'       dsply                   packed1
     c                   else
     c     'Parm1'       dsply                   zoned1
     c                   endif

     c                   if        p_zoned2 = *NULL
     c     'Parm2'       dsply                   packed2
     c                   else
     c     'Parm2'       dsply                   zoned2
     c                   endif


     c                   eval      *inlr = *on
     c                   return




+---
| 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 thread ...

Replies:

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.