Im really sorry to have caused you to spend time without being clear.
"RED WHITE" or "RED 0 WHITE 100" - will produce a smooth gradient from red to white
Any other numbers will produce an error or nothing.
so consider producing this image (made with your script)
To produce this we must set the command at "RED RED 90 WHITE"
However to produce this
we must write
"RED WHITE 27 WHITE"
In my view it would be simpler to assume that the first colour will always start at zero because this is fundamentally true - and then the subsequent number is where it finishes (or the next one starts). THe last colour always finishes at 100.
So the numbers merely represent a percentage of distance across a line. A good example is the gradient maker in photoshop.
So for me to produce the first image I would simply write
"RED 90 WHITE"
the second image
"RED 27 WHITE"
For my own purposes I have created a work around function which checks to see if the first colour is greater than 0, else if the second colour is less than 100, else assume no numerical colour stops.