Problem with DiscreteUniform giving indices out of bounds

Couple of questions regarding the code: what’s the value of nTemp? Also what does box.match do?