Mid() and StringField() to allow negative start positions

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Neil
Enthusiast
Enthusiast
Posts: 198
Joined: Wed Feb 29, 2012 8:04 am
Location: Melbourne, AUS

Mid() and StringField() to allow negative start positions

Post by Neil »

No big deal (and I know that I can write my own functions) but it would be handy to have the inbuilt PB functions allow negative start positions.

This would indicate that counting is to start from the end of the string.

Mid("This is a string", -2) = "ng"

Mid("This is a another string", -4, 2) = "ri"

StringField("Hello I am a splitted string", -2, " ") = "splitted"

StringField("ABC/DEF/GHJ/KLM/NOP", -2, "/ ") = "KLM"

I have seen that a similar request has been lodged for StringField() but only for using -1 as an indicator to start count from end.

I couldn't find request for Mid() and this request combines requests.