A: |
There is a lot of methods. I suggest the following one:
ESI ptr;
int result;
int i = 1; // Just an example
int j = 2;
push_parse_text ("[[11,12][21,22]]"); // An example matrix
ptr = locate_element (i,j);
result = GetIntArg (ptr); // (assumed that elements are ints)
where 'locate_element' is an user-written function, which may be
implemented as follows:
ESI locate_element (short m, short n)
{
short i;
ESI ptr = top_estack-1;
for (i = 0; i < m-1; i++) ptr = next_expression_index (ptr);
ptr--;
for (i = 0; i < n-1; i++) ptr = next_expression_index (ptr);
return ptr;
}
You can use it as-is, but it will be much better if you can
understand how it works.
|