Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

two-dimensionla array ???? 1

Status
Not open for further replies.

berndwik

Programmer
Oct 9, 2003
4
DE
Hello,
I need a two-dimensinal Array in RPG like
A(i)(j) = k or A(i,j) = k
Any Tips ?
 
Two dimensional arrays are not supported in RPG.
What are you trying to do?

RedMage1967
IBM Certifed - RPG IV Progammer
 
Hello,

abstract : a network with weighted
I have several locations (p.e. towns) and transportation times between these location.
p.e.
locations a,b,c,d,e,f,g,h,i..
tsp-time(a,b) = 2;
tsp-time(b,a) = 1;
tsp-time(a,c) = 3;
tsp-time(a,d) = 6;
means 2*(number location)! possible tsp-times.
Target is a optimized tsp-planning.
Getting the tsp-time by chain isn't a good way.
 
You can fake it using two arrays. If you had the transport times defined as 5,0 numerics for 10 locations you could do
Code:
D Array1     S                 5  0 DIM(10)
D Array2     S                50    DIM(10)

C         MoveA  Array2(6)     Array1
C         Eval   WorkField = Array1(3)
...
C         Eval   Array1(8) = 16
C         MoveA  Array1        Array2(1)
would retrieve the value for tsp(3, 6) into WorkField or place value 16 into tsp(8, 1). If you wanted to be smart you could define a couple of procedures
Code:
 *                                                
P GetTSP          B                   Export      
 *                                                
D GetTSP          PI             5  0               
D  x                             2  0 VALUE   
D  y                             2  0 VALUE   
 *                                                
C         MoveA  Array2(x)     Array1
C         Return Array1(y)

P                 E
 *                                                
P SetTSP          B                   Export      
 *                                                
D SetTSP          PI                            
D  x                             5  0 VALUE        
D  y                             2  0 VALUE       
D  Value                         2  0 VALUE       
 *                                                
C         Eval   Array1(x) = Value
C         MoveA  Array1        Array(y)
C         Return

P                 E
.
.
C         Eval   WorkField = GetTSP(3: 6)
C         CallP  SetTSP(8: 1: 16)
RedMage I know it isn't /free, but they don't use it in this shop and they take a dim view of contractors using company time to learn about new ways of skinning cats.

PeteJ
(Contract Code-monkey)

It's amazing how many ways there are to skin a cat
(apologies to the veggies)
 
Pete, no problem. I've been buried this morning by customers making changes to data and forgetting to inform me about it (then they wonder why their statements and such are screwed up!!). Really haven't had time to look at this.

RedMage1967
IBM Certifed - RPG IV Progammer
 

*
In RPG you can set up a two dim array using the occurs clause. Consider:-

Col Col Col Col Col Col
1 2 3 4 5 6
Cost
Price

Cost
Price

Cost
Price

Cost
Price

Cost
Price

Code as:-


* Value Array By Column
DD1COLS DS OCCURS(6) INZ
D COST 20 3 DIM(5)
D PRICE 20 3 DIM(5)
*
.
.
.
*
* Set D1COLS Cost(3,2) to 50 and Price(3,2) to 100
3 OCCUR D1COLS
EVAl COST(2) = 50
EVAL PRICE(2) = 100


Dazed and confused
 
@skittle

This is what i searched for. excellent !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top