× 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: Floating Point Question
  • From: bmorris@xxxxxxxxxx
  • Date: Fri, 13 Aug 1999 10:26:21 -0400




Nelsom C. Smith <ncsmith@gate.net wrote:

>...
>I didn't use that method or the movel method for packed fields because I
>didn't want to have to choose between 900 different packed field sizes.  For
>them, I just counted bits and put the numbers, decimal point, & sign
>directly into an alpha field.  Every other type seems to work ok with the
>Movel (I haven't gotten to blobs yet, but I assume they will work like
>varchars).
>...

For packed, since the decimal point isn't really there, you really only need 30
different lengths to choose from to get a substringable (zoned) form, then you
could handle the decimal point and sign the same as you are already handling
zoned.  You could also try the MI builtin _LBCPYNV which can convert from packed
to zoned (see example code below):

Blobs ... you need embedded SQL to get that data out.  RPG itself can't see the
blob data.

Barbara Morris

----------------------------------------------------
Here's  a little toy program I wrote a while ago that uses lbcpynv to convert
from packed to zoned:

D DPA_Template    DS                  based(pDPA_Template)
D   DPA_type                     1A
D   DPA_len                      5I 0
D     DPA_frac                   1A   overlay(DPA_len:1)
D     DPA_digit                  1A   overlay(DPA_len:2)
D   DPA_res                     10i 0
D T_ZONED         C                   x'02'
D T_PACKED        C                   x'03'

D cpynv           pr                  extproc('_LBCPYNV')
D    tgtNum                       *   VALUE
D    tgtAttr                          LIKE(DPA_Template)
D    srcNum                       *   VALUE
D    srcAttr                          LIKE(DPA_Template)

 * If you are on V4R4 or later, you can use 3U 0 for the
 * frac and digit values and set the values directly
 * in the template without using this binchar stuff.
D                 ds
D   bin                          5i 0
D   binchar                      1a   overlay(bin:2)

D packedDesc      S                   LIKE(DPA_Template)
D zonedDesc       S                   LIKE(DPA_Template)

 * Sample data

D p               DS
D   pval                         7P 3 inz(-1234.567)
D s               DS
D   sval                         7S 3 inz(*hival)

 * Setup the packed descriptor
C                   eval      pDPA_Template = %addr(packedDesc)
C                   eval      DPA_Template = *allx'00'
C                   eval      DPA_Type = T_PACKED
 * Setup the length part
C                   eval      bin = %len(pval)
C                   eval      DPA_digit = binChar
C                   eval      bin = %decpos(pval)
C                   eval      DPA_frac = binChar
 * Setup the zoned descriptor like the packed one
C                   eval      zonedDesc = packedDesc
C                   eval      pDPA_Template = %addr(zonedDesc)
C                   eval      DPA_Type = T_ZONED
 * Convert from packed to zoned
C                   callp     cpynv(%addr(s) : zonedDesc :
C                                   %addr(p) : packedDesc)
 * Debugger: ===> EVAL sval:x F1F2F3F4 F5F6D7
C                   return


From QSYSINC/MI H, members MICPTCOM and LBCPYNV:

 typedef _Packed struct _DPA_Template_T {
                                    /* Data Pointer Attr template */
   char              Type;          /* Scalar type                */
   short             Length;        /* Scalar length:             */
                                    /*   0-7  = fractional digits */
                                    /*          (zoned or packed) */
                                    /*   8-15 = total digits      */
   int               reserved;      /* reserved for future use    */
                                    /* and must be set to zero    */
 } _DPA_Template_T;
 #define _T_SIGNED   0x00
 #define _T_FLOAT    0x01
 #define _T_ZONED    0x02
 #define _T_PACKED   0x03
 #define _T_CHAR     0x04
 #define _T_ONLYNS   0x06
 #define _T_ONLYN    0x07
 #define _T_EITHER   0x08
 #define _T_OPEN     0x09
 #define _T_UNSIGNED 0x0A

 void _LBCPYNV ( _SPCPTR,              /* Receiver                  *
                 _DPA_Template_T *,    /* Receiver attributes       *
                 _SPCPTRCN,            /* Source                    *
                 _DPA_Template_T * );  /* Source attributes         *



+---
| This is the Midrange System Mailing List!
| To submit a new message, send your mail to MIDRANGE-L@midrange.com.
| To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com.
| To unsubscribe from this list send email to MIDRANGE-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 ...


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.