While I input an expression “$perimeter 9”, the expression will be parse and get the partIndex = 9 at the code below.  and will use partIndex at  , So the index out of range.
While I input an expression “$perimeter 9”, the expression will be parse and get the partIndex = 9 at the code below.

and will use partIndex at

, So the index out of range.