@tomleslie You are correct. wrt. D being local to the OP's proc. In fact, I think your and my replies crossed as I do not remember having seen yours before writing mine.
Be that as it may; your eqTqble.mw works (of coursse).
I do have two comments:
First: the table produced does not behave like a true 3-d array. An expression like
does not evaluate. The OP may, however, declare DD as an Arrary like this:
global DD:=Array(1..n,1..n,1..n); # just add the Array assignment to the original declaration
after which (s)he can e.g. evaluate one slice of the array:
or make this a Matrix or whatever.
Secondly; in larger projects the use of global variables should be discouraged as endless pain and suffering will occur when variables change value seemingly randomly and initiated in different procedures or modules. Better to either return the Array or table from the proc, or wrap the thing in a module and use exports. For a single proc this is obviously not a grave concern, but the OP should be aware of this.