my experience is
that you typically only want to reference one element at a time to
either save or retrieve the element's contents. With RPG IV, my
preference is to just code a little subprocedure to return the index
when passed the desired dimensions.
c eval Array( GetArrayIndex( X: Y )) = A
or
c eval A = Array( GetArrayIndex( X: Y ))
This technique allows you to code as many dimensions as you want, and
still be (relatively) readable. I don't put this one in a service
program, because I change the name of the procedure based on the
array, and change the number of arguments and array sizes.
By making the arguments Const, you can pass a variable, expression, or
constant for each dimension. For example, a simple program:
D Entry S 10A
D Array S Like( Entry )
D Dim( 6000 )
D GetArrayIndex PR 5I 0
D X 5I 0 Const
D Y 5I 0 Const
C Eval Array( GetArrayIndex( 1: 2 )) =
'Rhinoceros'
C Eval Entry = Array( GetArrayIndex( 1: 2
))
C Eval *InLR = *On
P GetArrayIndex B
D GetArrayIndex PI 5I 0
D X 5I 0 Const
D Y 5I 0 Const
D Array_Size_X C 100
D Array_Size_Y C 60
C Return (( X - 1 ) * Array_Size_X + Y )
P E作者: qingzhou 时间: 2004-11-24 19:52 标题: RPG中是否真的無法解決二維陣列問題?