Some ideas? This shows up how to do the whole function, maybe with some changes.

Ahh, and I still think it's possible to do the Mid function with C.