Minimize element.substring errors + fix math

This will prevent stacktraces / failure to run if substrings are used
with really *really* wrong input indexes. (There are situations where it
can happen out of the scripters control, can't blame them)
It also corrects the counting of the end index (the character at
endIndex is not included in Java)... it should be in dScript. This way
substring[1,1] returns one letter rather than nothing at all. This is
generally what people logically expect to occur, though there may be
trouble with 'endIndex - startIndex' not being equal to the returned
length... anyone who gets that far in a calculation can figure out to
add 1.