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








"Scott Klement" <infosys@klements.com> on 08/11/99 08:09:27 AM

Please respond to RPG400-L@midrange.com












Subject:  Re: Multi Dimensional Array




Hmmm... in which version of RPG?

In RPG IV, the %subst() BIF allows you to access/change the areas
within a character variable without the need for a second dimension
on your array.

c                   eval      A = %subst(Array(X): Y: 1)
   or
c                   eval      %subst(Array(X): Y: 1) = A


Otherwise, simulating a two dimensional array isnt very difficult,
either.  In your example, you wanted an two dimentional character
array, 100 x 60.  So you can code it like this (and the same concept
should also work in RPG III)

D Array           S              1A   DIM(6000)

c                   eval      Array(((X-1)*60) + Y) = A
   or
c                   eval      A = Array(((X-1)*60) + Y) = A


(or, if you're still using RPG III)

E                    ARR      6000  1
 *
C           X         SUB  1         I
C                     MULT 60        I
C                     ADD  Y         I
C                     MOVE A         ARR,I
C                     MOVE ARR,I     A

Make sense?


Hi Scott,

Thanks a lot for your reply, I think I logic will work  but for 'simulating 2
dim arrays'(the II one) logic, I see that this logic will do something else.


Clarification:

How will compiler know to jump to next record? Each array record has to be of 60
chars only. So after 60*(X-1) + Y, it'll take trailing blanks too that are there
after 60 chars cause there are no delimiters. Right?

e.g.
<----------------60----------------------><------20------>
<------------(35 ... 50)-----------------><------20------>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
...

KKKKKKKKKKKKK(10 th Rec)KKKKKKKKKKKKKKKKKK
...

Let's say I have to change 35th to 50th position in 10th record.

As per above logic,

X = 10
Y = 16
A = 'New Stringbbbbb'

D Array           S              1A   DIM(6000)

C                   eval      Array(((X-1)*60) + Y) = A

(X-1)*60 + Y will be (10 - 1) * 60 + 16 = 556.
So, starting 556th position, the string will be changed. And this will include
20 blanks after each record. So, instead of 10th record, the 6th record will
have a changed string starting position 76. This is not desired. And this is
because of no delimiter.

Am I missing something?

Thanks,
Rajeev.















"Rajeev Asthana" <Rajeev_Asthana@paramount.com> wrote:
>
> Hi All,
>
> Is there any way to process multi-dimensional array in RPG?
> For example, there is a complile time array with 100 records and eac
>  record
> with 60 chars.
> If I want to change 35th- 50th positions of the 10th records, how ca
>  I do it?
>
> Any help is appreciated.
>
> Thanks in advance.
>
> Rajeev.
>
+---
| 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
+---END







+---
| 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
+---END



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.