I have a question:
Y X
Tabel a is a array multidimensional --> a(1024,20)
I load in to array a Text from 6000 row where:
in a(1,1) is present the row 1 of original text, in a(1024,1) is present then row 1024 of original test and in a(1024,2) is present the row 2048 of original text , in a(1,3) is present the row 2049 the ooriginal text ecc....
fig.
1 2 3 4 \(X array\)
1
.. > \( Y array\)
..
...
1024 1024 1024 1024
I find a procedure / function to point a cell(x,y) where in input are the l row of original text loaded.
es function Position (row Y, column x)
-- solve \--
POSFOUND=xxxxxx in the original text.
and
function PosArray ( roworiginal x )
Rowxres and Columres return the array position
tanks
I'm not sure I follow you. But here is an attempt at what I think you may want:
#! /usr/bin/ksh
nline=0
while read line ; do
((element=nline%1000))
((narray=nline/1000))
eval array${narray}[$element]=\$line
((nline=nline+1))
done < bigfile
((count=narray*1000+element))
while echo enter x,y \\c ; read x y ; do
echo x = $x
echo y = $y
((lineno=(y-1)*1024+x))
echo lineno = $lineno
((element=(lineno-1)%1000))
((narray=(lineno-1)/1000))
echo element = $element
echo narray = $narray
eval value=\"\${array${narray}[$element]}\"
echo value = $value
done
echo
exit 0
The first paragraph just reads a file into a very large array. Ideally, I would use a 6000 element array. But ksh does not guarantee that arrays that large will work. So I use a collection of arrays, each with 1000 elements. To access element 1234, I use real element 234 of array 1. Then I have a loop that reads coordinates and calculates the line number coresponding to those coordinates. Then I convert the line number to array/element and grab the value. To test it, I created a bigfile with:
yes | awk '{print NR,$0}' | sed 6000q > bigfile
how you declare a collection of array ???
why in you procedure not use the sintax Array[x,y] but eval array${narray}[$element]=\$line ???
very taks
You just start using an array, no need to "declare" it. ksh does not have multi-dimensioned arrays. It only has one dimensional arrays. So I had to improvise.