Segment: Start (2) + length (1) - 1 exceeds text length (0)

How to debug?

Kindly click on on the global variables and do Do it else remove all the blocks and use one label to catch the output then design the logic based on it. First make sure what is the output then apply the logic . With the help of blocks nobody can help you. All will say check your output or the global variable is not in that length