MinMax NXT-G Block
software/
NXT Repository/Programming/NXT-G/

This small NXT-G allows to get the maximal and minimal value of some varying input. This can be done with NXT-G MyBlocks using variables, but then you can’t easily place more then one such MyBlock in your program (unless you duplicate the block, changing the variable names..). As seen in the above sample code, the MinMax block usually should reside in a loop, and must be “Reset” at the first loop iteration (here I compare the counter to zero). Also, make sure that the input you put in is stable at the first iterations. For example, for the US measurement above I have another Distance Sensor block before the loop to ensure the sensor has enough time to produce meaningful output at the first iteration (otherwise I got maximal distance of 100 inches regardless of what I tried to do to the US sensor…). The block can be downloaded here.