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



Dan,

You should add externally defined datastructures of the records that you
use.
Otherwise the program will put the fields in alphabetical order in his
memory (FLD1, FLD11, FLD2, FLD22 etc.), and not in the sequence that you use
in your file definition. When you add the externally defined datastructure
of the files, it uses that sequence instead of the alphabetical sequence,
and then you can use pointers to overlay multiple fields.

Regards, Wilbert




----- Original Message ----- 
From: "Dan Belu" <danbelu@xxxxxxxxxxx>
To: <rpg400-l@xxxxxxxxxxxx>
Sent: Tuesday, January 27, 2004 9:15 PM
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 ...

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.