× 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'm sure someone will correct me , but just because flda101, flda102,
etc... are contiguous in the file doesn't mean that they are contiguous in
memory. You may have to order the fields in a data structure defined as a
array like this:

 D                 DS
 Dunitsds                  1    120  3
 D                                     dim(12)
 D @units1                 1     10  3 INZ
 D @units2                11     20  3 INZ
 D @units3                21     30  3 INZ
 D @units4                31     40  3 INZ
 D @units5                41     50  3 INZ
 D @units6                51     60  3 INZ
 D @units7                61     70  3 INZ
 D @units8                71     80  3 INZ
 D @units9                81     90  3 INZ
 D @units10               91    100  3 INZ
 D @units11              101    110  3 INZ
 D @units12              111    120  3 INZ

@units1 - @units12 are fields in a file. I can access these fields using
unitsds(index). Or I can take a corresponding data structure and move one
to the other with one instruction.

Thanks,

Mark

Mark D. Walter
Senior Programmer/Analyst
CCX, Inc.
mwalter@xxxxxxxxxx
http://www.ccxinc.com


|---------+----------------------------->
|         |           "Dan Belu"        |
|         |           <danbelu@xxxxxxxxx|
|         |           om>               |
|         |           Sent by:          |
|         |           rpg400-l-bounces@m|
|         |           idrange.com       |
|         |                             |
|         |                             |
|         |           01/27/2004 03:15  |
|         |           PM                |
|         |           Please respond to |
|         |           RPG programming on|
|         |           the AS400 /       |
|         |           iSeries           |
|         |                             |
|---------+----------------------------->
  
>------------------------------------------------------------------------------------------------------------------------------|
  |                                                                             
                                                 |
  |       To:       rpg400-l@xxxxxxxxxxxx                                       
                                                 |
  |       cc:                                                                   
                                                 |
  |       Subject:  pointer based arrays                                        
                                                 |
  
>------------------------------------------------------------------------------------------------------------------------------|




Here is the situation:

             I want to convert filea with a format like:
flda1 flda2 flda101 flda102 ... flda124 flda201 flda202 ... flda224

             to fileb that looks like:
fldb1 fldb2 fldb11 fldb21
fldb1 fldb2 fldb11 fldb21
.
.
.
fldb1 fldb2 fldb11 fldb21 (times 24)

The fields flda101, flda102, ..., flda124 have the same size and map all to

fldb11 and
                flda201, flda202, ..., flda224 are alike and map to fldb21

I tried to use pointer based arrays to load the data in an elegant way.
But is not working although is suppose to.
The problem is that RPG does not load the data into the fields that aren't
directly used in the program.

This is the code I use:

*
* C_Template convert filea - horizontal to fileb - vertical
*
*----------------------------------------------------------------
ffilea     if   e           k disk
ffileb     uf a e           k disk

darra1            s              3  0 dim(24) based(ptr1)
darra2            s              8  0 dim(24) based(ptr2)
dptr1             s               *   inz(*null)
dptr2             s               *   inz(*null)

c                   dou       %eof(filea)
c                   clear                   ptr1
c                   clear                   ptr2
c                   read(e)   filea
c                   if        %eof(filea)
c                   leave
c                   endif
c                   clear                   c_rec
* set pointer1 and pointer2
c                   eval      ptr1 = %addr(flda101)
c                   eval      ptr2 = %addr(flda201)
* at this point arra1 and arra2 should have all the data loaded.
c                   z-add     0             i                 2 0
* requirements and their dates
c     1             do        24            i
c                   if        ptr1 <> *null
c                   eval      fldb1 = arra1(i)
c                   endif
c                   if        ptr2 <> *null
c                   eval      fldb2 = arra2(i)
c                   endif
c                   write     c_rec
c                   enddo

c                   enddo

c                   seton                                        lr

The fileds flda102, flda103 and so on and the corresponding array elements
will have zero values even if the input file has data in these fileds.
The same with flda202, flda203 ... The only ones that get the data are
flda101 and flda201 because I specifically use it in the code.

Any help would be greatly appreciated.

Dan

_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE*
http://join.msn.com/?page=features/junkmail
http://join.msn.com/?page=dept/bcomm&pgmarket=en-ca&RU=http%3a%2f%2fjoin.msn.com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca


_______________________________________________
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.







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.